Page 1 of 1

how do i match any amount of any character?

Posted: Mon Nov 27, 2006 10:53 pm
by pedrotuga
Damn, regex is defenatly not for me, i try try but there is to much that one should put inside a little brain.

I google a bit but googling for regex documentetion is pain in the ass.

how do i match something like

Code: Select all

blablablabla [any amount of any character] bloobloo
?

Posted: Mon Nov 27, 2006 10:57 pm
by feyd
The "any character" metacharacter is the period: .

To allow zero or more matches to the preceding unit: *

By default most will be greedy, so it will find the longest segment. If you wish to find the shortest segment, add a question mark after the trailing *

Posted: Mon Nov 27, 2006 11:18 pm
by pedrotuga
Thanks feyd. You are efficient, period.

I am getting this error

Code: Select all

Warning: ereg_replace() [function.ereg-replace]: REG_BADRPT in index.php on line 35
I think it should be some unescaped chars.

Which ones need to be escaped?

Posted: Tue Nov 28, 2006 5:13 am
by GeertDD
Use preg_replace() instead. I guess the POSIX regex flavor doesn't support ungreedy matching. PCRE does for sure.