Page 1 of 1

Some general questions

Posted: Mon Aug 27, 2007 4:21 am
by WaldoMonster
I have played around with RegexBuddy and PHP Regular Expression last days.
And have some unanswered questions.

Is there functional a difference between these two expressions?
Witch is preferred?

Code: Select all

^(leading|)(start.*)
^(leading)?(start.*)
I assume there is no difference between these PHP Regular Expression?
I found the last two better readable in combination with the / escape.

Code: Select all

'\(something.*)\'
'%(something.*)%'
'#(something.*)#'
So far I found these options in PHP:
s Dot matches new line
i Case insensitive
m ^$ match at line break
Are there more options?

Thanks,

Willem

Re: Some general questions

Posted: Mon Aug 27, 2007 7:01 am
by stereofrog
WaldoMonster wrote: Is there functional a difference between these two expressions?
Witch is preferred?

Code: Select all

^(leading|)(start.*)
^(leading)?(start.*)
There's no logical difference, however ? is far more common.
I found the last two better readable in combination with the / escape.

Code: Select all

'\(something.*)\'
'%(something.*)%'
'#(something.*)#'
Another common delimiter is tilde (~), imo it's more readable than %.
# has its uses in regexp.
Are there more options?
Yes, see

http://www.php.net/manual/en/reference. ... ifiers.php

Posted: Mon Aug 27, 2007 2:35 pm
by WaldoMonster
Thanks for the help.