dracoblue.net

preg_match multiple lines

If you try to use preg_match on strings, which do have multiple lines you run into the problems that they actually won't match at all.

This can be easily fixed by adding s-modifier, so:

/\[(code)\](.*?)\[\/code\]/

becomes to

/\[(code)\](.*?)\[\/code\]/s

and works like a charm!

In open source, php by
@ 04 Jul 2008, Comments at Reddit & Hackernews

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About