M
Michael Vilain
Originally, I was using
$value =~ s/<.*>//g;
to strip HTML tags from a variable. It actually stripped everything
from the first "<" to the last ">" after the ending tag. I found this
regex in this group:
$value =~ s/\<[^\<]+\>//g;
and I'm trying to parse it out and figure out why it works. First off,
some questions:
- why escape the "<"? It's not one of the meta characters that has
special meaning in a regex.
- what's the difference between using ".*" to match any string and "+"
to match a repeat of the character class "[^\<]".
Just trying to deepen my understanding of regex. It's like whitewash --
it gets more opaque with multiple coats.
TIA,
/MeV/
$value =~ s/<.*>//g;
to strip HTML tags from a variable. It actually stripped everything
from the first "<" to the last ">" after the ending tag. I found this
regex in this group:
$value =~ s/\<[^\<]+\>//g;
and I'm trying to parse it out and figure out why it works. First off,
some questions:
- why escape the "<"? It's not one of the meta characters that has
special meaning in a regex.
- what's the difference between using ".*" to match any string and "+"
to match a repeat of the character class "[^\<]".
Just trying to deepen my understanding of regex. It's like whitewash --
it gets more opaque with multiple coats.
TIA,
/MeV/