| Author |
Need some help in regular expression pattern
|
Srikkanth Mohanasundaram
Ranch Hand
Joined: Feb 07, 2007
Posts: 185
|
|
Hi all,
I'm a bit stuck with the following code that i wrote to match hyperlinks in a HTML string.
The pattern actually matches the first anchor but I need it to identify the second anchor in there as well, i know that the pattern is defined that way. Please let me know how i intersect in the group to leave out "/a> " just this word. Or please let me know if there is a better way to do this.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
It would help, if you explain to us, what portion of the string that you are trying to match.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Srikkanth Mohanasundaram
Ranch Hand
Joined: Feb 07, 2007
Posts: 185
|
|
I'm trying to match the anchors.
Thanks,
Srikkanth
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
Srikkanth Mohanasundaram wrote:I'm trying to match the anchors.
Thanks,
Srikkanth
That part, I figured out. What I could not figure out from your description was... Did you want only the <a> tag? Did you also want the </a> tag too? Or did you only want what was between the two tags?
It would be helpful if you showed us some sample data, along with what you expect extracted from the same data.
Henry
|
 |
Srikkanth Mohanasundaram
Ranch Hand
Joined: Feb 07, 2007
Posts: 185
|
|
Hi,
My output should be something like this
What i need actually is to match the whole anchor tag, but this code actually doesn't know to find the end of an anchor tag and it goes ahead to match it too.I just want to say it that "/a>" this is the end of the pattern.
Thanks,
Hope it is clear
Srikkanth
|
 |
Brian Spindler
Greenhorn
Joined: May 17, 2007
Posts: 29
|
|
changing your pattern to:
will get you what you want. you must specify the end of the regex, you might want to replace the .*? with something more specific.
|
 |
Srikkanth Mohanasundaram
Ranch Hand
Joined: Feb 07, 2007
Posts: 185
|
|
Thanks a lot
|
 |
 |
|
|
subject: Need some help in regular expression pattern
|
|
|