[thelist] Regexs and headaches
kasimir-k
evolt at kasimir-k.fi
Thu Feb 9 07:13:25 CST 2006
Dan Parry scribeva in 09/02/2006 12:28:
> I have a regex problem that is giving me major hassles. the preamble is that
> the expression looks for opening HTML tags in a textarea value
> But (and this is a big but) it can't find single letter tags
> Here is the regex:
/
\< so we start with a "<"
[^\/] then one character which is not "/"
([^<>]*) and zero or more characterse that are not "<" nor ">"
[^\/] one more character which is not "/"
> and finally one ">"
/g
so we require twice one charecter... not what we want, as two is more
than one.
< again let's start with a "<"
[^\/]+ after opening bracket we want one or more characters,
but they should not be "/", as we don't want
(self)closing tags
? lets make it lazy
> and end up with closing ">"
which gives us /<[^\/]+?>/g
untested though, so let us know how it works :-)
.k
More information about the thelist
mailing list