how do i match any amount of any character?

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

Moderator: General Moderators

Post Reply
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

how do i match any amount of any character?

Post 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
?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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 *
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post 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?
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Post by GeertDD »

Use preg_replace() instead. I guess the POSIX regex flavor doesn't support ungreedy matching. PCRE does for sure.
Post Reply