vlasin
vlasin

Reputation: 11

Replace eregi_replace with preg_replace

How do I convert this function with this parameters

eregi_replace('<[^>]*>', '', $stringToDisplay)

to preg_replace?

Upvotes: 1

Views: 1079

Answers (2)

Gumbo
Gumbo

Reputation: 655239

The PCRE regular expressions require delimiters that separate the pattern from optional modifiers (in this case i to reflect a case insensitive match):

preg_replace('/<[^>]*>/i', '', $stringToDisplay)

But since there are not letters that need to be interpreted without case, you can omit the i modifier.

And if you happen to try parsing HTML or a similar markup language with regular expressions, consider using a proper parser.

Upvotes: 4

ajreal
ajreal

Reputation: 47321

Try

preg_replace('/\<[^>]*\>/i', '', $stringToDisplay)

More details - http://php.net/manual/en/function.preg-replace.php

Upvotes: 1

Related Questions