Page 1 of 1
Regular Expressions
Posted: Mon Nov 04, 2002 8:59 pm
by EricS
I've always had problems with them. But here is my current question. Does the | have a special meaning in regular expressions?
Second. Im trying to disect the following code:
Code: Select all
$string = ereg_replace('<(ї^>]|\n)*>', '', $string);
This will replace <, >, and the new line character with an empty string character. Is that the correct disection of this regular expression?
Thanks for your help.
Replace
Posted: Mon Nov 04, 2002 9:27 pm
by mindmeddler2002
umm...
its been a while...
i wrote a program a while back that replaced a few things, i only used one thing at a time...
This seems a little strange that they have it seperated...
<([^>]|\n)*>
I actually think it replaces all those
except i think the \n is together
so it replaces any < or ( or [ or ^ or > or ] or | or \n or ) or * or > with a a blank space?
i am kind of confused why they repeate > 2 times.... I dont think it means anything though... Seems they skiped { } ~ _ those also seemed to be logical things to want to replace...
no clue about the |.
I know in math is means Such That...
Not sure if it has the same meaning in programing....
like 1.2 ~ 1
or something, i forget pascal...?
Posted: Mon Nov 04, 2002 11:21 pm
by mydimension
not really.
this roughly translates into: any < followed by (any number of characters except > OR a single newline character) and ending in >
take a look at the comment by luciano_at_braziliantranslation.net at
http://www.php.net/manual/en/ref.regex.php