Archived Boards and Threads... > Parham's PHP Tutorials

PHP Lesson 17 - Regular Expressions

<< < (2/4) > >>

[Unknown]:
The ^ and $ can be anywhere, here's an example:

/abc(d|$)/ -> matches anything + "abc" or anything + "abcd" + anything.

/^(ab|cd)$/ -> matches: 'ab' OR 'cd'.  The problem I think you are having is the word OR - in general programming, or usually means "this, that, or both" but in regular expressions it means "this, that, but not both."

-[Unknown]

Parham:

--- Quote from: [Unknown] on December 07, 2003, 12:30:21 AM ---/abc(d|$)/ -> matches anything + "abc" or anything + "abcd" + anything.
--- End quote ---

it's still _technically_ at the end of the regex though, no?  You can either choose to end with a d or "abc" must show up at the end of the string.  What I meant was that you can't do something like "/beginning(end)$more/".  Meaning "end" should match at the end of the string.  What I meant was that regular expressions are very linear: match this, then this, then this or this, then this...

[Unknown]:
Yeah... that's true, they are incredibly linear.

-[Unknown]

Tyris:
ok, thanks to both of you... its pretty clear to me now :)

pulpitfire:
whew...i'm starting to understand this...good job :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version