Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
pedrotuga
Forum Contributor
Posts: 249 Joined: Tue Dec 13, 2005 11:08 pm
Post
by pedrotuga » Mon Nov 27, 2006 10:53 pm
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
?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Nov 27, 2006 10:57 pm
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 *
pedrotuga
Forum Contributor
Posts: 249 Joined: Tue Dec 13, 2005 11:08 pm
Post
by pedrotuga » Mon Nov 27, 2006 11:18 pm
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?
GeertDD
Forum Contributor
Posts: 274 Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium
Post
by GeertDD » Tue Nov 28, 2006 5:13 am
Use
preg_replace() instead. I guess the POSIX regex flavor doesn't support ungreedy matching. PCRE does for sure.