• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Need some help in regular expression pattern

 
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to match the anchors.
Thanks,
Srikkanth
 
Henry Wong
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot
 
reply
    Bookmark Topic Watch Topic
  • New Topic