0

I want to know what is the proper regular expression for that :

In an action unprecedented during 12 years of war in Afghanistan, the commandant of the Marine Corps is firing two top generals. See why: 

<a onmouseover="LinkshimAsyncLin.swap()>Generals fired over Taliban attack </a><br/>security.blogs.cnn.com<br/>There were three investigations of the incident.

I want to do the following :

give me string starting of a tag which contains onmouseover="LinkshimAsyncLin.swap() in any position at properties area .. and end with the end of the remain string .. i mean from this a tag to end of the string

Note :

My friends, I know that using regex with html tag is very bad practice and i already have red that a lot but i want that for special case

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
eng.ahmed
  • 905
  • 4
  • 16
  • 38
  • 1
    It looks like you've just written a brief of your current task on StackOverflow instead of in your notebook. Show your attempts and explain your _specific_ problem. StackOverflow is not here to do your work for you – Bojangles Oct 01 '13 at 20:53
  • i don't know anything about regex but i want this expression urgently please – eng.ahmed Oct 01 '13 at 20:54
  • what language do you use? – Casimir et Hippolyte Oct 01 '13 at 20:55
  • 1
    Unfortunately, the warnings about not using regular expressions to parse HTML still apply. The string you are searching for may be simple, but you haven't provided any restrictions for how complicated the HTML around this tag could get. – mbeckish Oct 01 '13 at 20:59
  • i said i want from this a tag to the end .. get whole string after it – eng.ahmed Oct 01 '13 at 21:03
  • [Tony the Pony, He Comes...](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) – Zathrus Writer Oct 01 '13 at 21:09
  • 1
    "I know that using regex with html tag is very bad practice and i already have red that alot but i want that for special case". I can't see anything special about your case. – David Knipe Oct 01 '13 at 21:36

1 Answers1

0

Try this:

(?i)[^<>]++(?=<a\\b(?>[^>o]++|\\Bo++|o(?!nmouseover\\b))++onmouseover\\s*=\\s*[\"']?LinkshimAsyncLin\\.swap\\(\\)(?>[\"']|\\s|(?=>)))
Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125