Hey guys,

I need some help with preg_replace()

I have something like this....

{$gallery_20}

And I want to use preg_replace to replace it with nothing.... however gallery_20 can be anything... but im not sure on the patten...

Can anyone help please?
I don't understand how to change all this.... $patterns = array ('/(19|20)(\d{2})-(\d{1,2})'); (from php.net)

Dan

Recommended Answers

$your_string = preg_replace('/\{\$\w+\}/', '', $your_string);
Jump to Post

All 3 Replies

$your_string = preg_replace('/\{\$\w+\}/', '', $your_string);

Thanks mate!

How do you know what to put? I couldn't find anything on the web about it :(

Dan

How do you know what to put? I couldn't find anything on the web about it :(

I used to go to http://www.regular-expressions.info/ to learn and I use (when needed) RegExBuddy to build/test them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.