PHP RegEx: (a|b)*c --> Could it return just 'c'?

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
CallumD
Forum Newbie
Posts: 11
Joined: Wed May 03, 2006 12:36 am

PHP RegEx: (a|b)*c --> Could it return just 'c'?

Post by CallumD »

I am on a RegEx tutorial and it's stating that:

"(a|b)*c": a string that has a sequence of alternating a's and b's ending in a c.

Given that the asterisk (*) means zero or more, wouldn't this type of string search also just return every instance of 'c'?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Try it. :)
CallumD
Forum Newbie
Posts: 11
Joined: Wed May 03, 2006 12:36 am

Post by CallumD »

Is there a program I can download to test POSIX regular expressions?

I am on my work computer, not my home computer which has a home server set up to test PHP scripts...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There is an application referenced in our own regex board that may be of interest.

viewtopic.php?t=33106
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Moved to Regex board.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply