Hi. Is there a regexp that can erase the <b style="whatever"> and the </b> in the following code, but leave bagels and blarneystones? I need this for my own context ad service.
The first one won't match if there's a newline within the tag (without using the /s modifier, '.' doesn't match \n). I believe the second's more efficient too, though I can't remember why.
ishnid, I think you're right about the second regex being more efficient. I don't remember exactly why either (and I'm not about to go wading through docs or Mastering Regular Expressions right now). Aarem, if you're going to go with one or the other, the second is probably better.
This is a good reference on this and backs up what I suspected. In particular, see the paragraph that begine "Tracking is another problem with both of them". Apparently "Mastering Regular Expressions" deals with this on page 226.
The first one is too greedy, and will remove everything between the first < and the last > Including the bagels and blarneystones. The second one works as expected as it only matches up to the closing > of a tag.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.