• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need some help in regular expression pattern

 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 22124
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


It would help, if you explain to us, what portion of the string that you are trying to match.

Henry
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to match the anchors.
Thanks,
Srikkanth
 
Henry Wong
author
Marshal
Pie
Posts: 22124
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic