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 3 of 3

Thread: Problem with Regular Expression

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with Regular Expression

    Hu Guys!

    I need some help with regular expression. I have to identify in an HTML code the following tag:

    <username/>

    However, i need to consider also the fact that after "<" there might be some blank characters, after "username" there might be the same situation, same thing for "/". So the situation is the following:

    "<" zero or more spaces "username" zero or more spaces "/" zero or more spaces ">"

    Now, I do not want the solution, but some hint to get that.

    Thanks,

    Luca


  2. #2
    Junior Member
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Regular Expression

    Maybe something like this:

    ^[<] \s* [username] \s* [\] \s* $[>]

    ??

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with Regular Expression

    Solved...here the solution

    String regex = "&lt;+\\s*+username+\\s*+/+\\s*+&gt;";

Similar Threads

  1. regular expression issue
    By flamant in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 22nd, 2012, 02:57 AM
  2. [SOLVED] Regular Expression Difficulties...
    By snowguy13 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 4th, 2012, 08:31 AM
  3. Regular expression handling
    By marquiseoflight in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 9th, 2012, 04:57 PM
  4. Regular Expression help
    By medoos in forum Java SE APIs
    Replies: 0
    Last Post: March 19th, 2011, 07:23 PM
  5. Simple Hashsets and regular expression problem !
    By burningflower in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 10th, 2011, 01:43 PM