Regex wrapping div tags round img tags

2009-07-02 Thread Matthew Allen
Hi, I'll really appreciate if anyone could help. I have image tags outputted to my page from a database, what can I write to to wrap div tags round the img tags so e.g; img src=...images/jpgs/ducks.jpg alt= / I would like to change it to; div class=coverimg src=...images/jpgs/ducks.jpg alt=

Re: Regex wrapping div tags round img tags

2009-07-02 Thread Nathan Strutz
A regex question on this list that doesn't already have 5 answers? Wow. Holiday weekend must be in full effect already. Ok, you want something like this... reReplace(string, (img[^]+), div class='cover'\1/div, ALL) That is... ( -- capture a sub-group img -- html image tags [^] -- anything not

RE: Regex wrapping div tags round img tags

2009-07-02 Thread Robert Harrison
Holiday weekend must be in full effect already. Yeah, my brain is just outside the door waiting for the rest of me to join it. Robert B. Harrison Director of Interactive Services Austin Williams 125 Kennedy Drive, Suite 100 Hauppauge NY 11788 P : 631.231.6600 Ext. 119 F : 631.434.7022

Re: Regex wrapping div tags round img tags

2009-07-02 Thread Peter Boughton
Regular Expressions are not designed for HTML manipulation of this sort. You should really be using a DOM parser and manipulating the data as a set of nodes. That said, here is a very basic regex replace that will work in the majority (but not all) situations: rereplace( SomeHtml , 'img[^]+'

Re: Regex wrapping div tags round img tags

2009-07-02 Thread Peter Boughton
A regex question on this list that doesn't already have 5 answers? Wow. Holiday weekend must be in full effect already. Nah, HoF was broken (again) earlier. I tried posting half a dozen times throughout the day but kept getting errors. Anyway, a single but significant difference in our