Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: advanced regular expression question

  1. #1
    Member
    Join Date
    May 2010
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default advanced regular expression question

    im real good with regular expressions in all kinds of languages
    however, theres still one trick i haven't quite touched in java
    when ur looping through with while(matcher.find())
    it finds the same pattern over and over
    but what if i have two patterns, and i want to find one, then keep parsing, then find the other, then keep parsing, then find the first again etc etc until it cant find() again?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: advanced regular expression question

    Post some code that shows what your are doing and what the problem is.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    May 2010
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: advanced regular expression question

    i havent done anything yet
    i thought i explained the problem pretty well

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: advanced regular expression question

    Ok, I'll wait until there is code that shows the problem and that can be used for testing.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: advanced regular expression question

    Huh, this is interesting. Apparently you can design a regex with the OR modifier. For example, this input with this regex:
    String input = "methodsTestingPurposesStringForTestingFor";
    String regex = "(Test)|(For)";
    Will find both the word "Test" and the word "For" in the input String. You learn something new every day.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  6. #6
    Member
    Join Date
    May 2010
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: advanced regular expression question

    o tyvm!!!!!!!!!!!!!!

Similar Threads

  1. Regular expression handling
    By marquiseoflight in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 9th, 2012, 04:57 PM
  2. Regular Expression To Catch Duplicates
    By daniel_el in forum Java Theory & Questions
    Replies: 1
    Last Post: February 7th, 2012, 12:06 PM
  3. [SOLVED] Pattern, regex (regular expression) case sensitivity question
    By chronoz13 in forum Java SE APIs
    Replies: 1
    Last Post: September 7th, 2011, 04:16 AM
  4. How to remove the regular expression from a string ?
    By srimanta in forum Java Theory & Questions
    Replies: 5
    Last Post: July 20th, 2011, 03:07 PM
  5. Regular Expression help
    By medoos in forum Java SE APIs
    Replies: 0
    Last Post: March 19th, 2011, 07:23 PM