Page 1 of 1
Replace src attribute in a string.
Posted: Wed Dec 05, 2007 3:59 pm
by JellyFish
Hey guys. This one's a bit tricky.
I have this big string of html. And I need a way to replace the first occurrence of anything in between [src="] and ["] or [src='] and ['] in javascript.
Posted: Wed Dec 05, 2007 4:08 pm
by feyd
That would probably be regex if it's not DOM elements.
Posted: Fri Dec 07, 2007 11:31 pm
by JellyFish
feyd wrote:That would probably be regex if it's not DOM elements.
It's not DOM elements. Like I said it's a string, stored in an attribute to an element.
I would think it would be regex. But how would I accomplish this? I could use the .replace() method. But I don't know how I could select anything and everything that's wrapped around qoutes and "src=". Could someone give me a hint on this one. I'm not that great at regex.

Posted: Sat Dec 08, 2007 7:27 am
by feyd
Start trying something. There are plenty of examples in the Regex forum.