Regular Expressions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Regular Expressions

Post 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('<(&#1111;^>]|\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.
mindmeddler2002
Forum Newbie
Posts: 21
Joined: Mon Nov 04, 2002 3:09 pm
Location: US, PA, Harrisuburg

Replace

Post 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...?
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post 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
Post Reply