Forum Moderators: coopster
I'm a complete newbie to PHP I'm trying to find a preg_replace example using wildcards that makes sense.
Here's what I'm trying to acheive.
I have a string of text formatted as follows.
someurl-c*.htm
what I want to replace is the -c*.htm so I'm left with just
someurl
c* is a wildcard could be c1, c2, c1000, etc..
I have tried to figure this out before posting but all examples I can find are a bit complex. Maybe it's just late :-)
(-c) says look for hyphen followed by the letter 'c'.
(.*) says 'everything after that'.
Whatever's not included in the match won't be replaced, and you're replacing the matched parts with nothing, so the result:
$subject="some-url"