You are viewing a single comment's thread from:

RE: I need to replace all url in string...

in #steemcodeit7 years ago

It seems as though you might be getting into "Attempted to parse HTML with regex; system returned Cthulhu" territory...

I don't really do regex stuff very much, granted, but if I had to do this personally, I'd just avoid regex and scan the whole string character-by-character.

What you seem to be looking for, basically, is strings beginning with https://steemitimages.com/0x0 that aren't inside HTML tags. So I think if you scan the string looking for that prefix, but any time you encounter the character <, skip to the next > you find, you'd be able to select only the instances of that prefix that you want.

There may be some odd special cases that would be problems there, but I can't think of any. As long as you have well-formed HTML, you shouldn't need to worry about nesting depth of the angle brackets or anything.