Forum Moderators: coopster
I use FCKeditor to allow users to input text that is transformed into HTML.
For images, it creates (I guess via the js
createElement) <img> tags instead of the <img /> needed for W3C XHTML validation. alt="" into alt="image" or <br> into <br />, and I want to enrich it like this: 1- search the string for
<img whatever is between this <img and the first following > > isn't preceeded by a /, <img WHATEVER> with <img WHATEVER /> Obviously I'm no regex guru, and although I know it's important and interesting to learn, I don't really have time now.
My main problem is part 3 : do the replacement if following
> isn't preceeded by / ps: I learned from previous posts that these 3 steps would fail if the
alt tags contains >, but alt texts could also be cleaned with regex. Do you think of any other caveat?
And if an update to your editor doesn't work for you, you may want to have a look at PHP's PCRE [php.net] functions and what is called negative lookbehind assertions.
cooper : thanks for you input, I will check that when time for regex will come... Hope I'll have the time soon to read "mastering regular expressions" as they seem really useful. Basic regex is quite greek to me, so imagine "negative lookbehind assertions".....
penders : you're right, the demo produces self closing img tags... #*$!?! After checking their roadmap, it seems the version I got was a buggy beta one, previous and actual do output correct xhtml.
Thanks again !