1

How do I convert this function with this parameters

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

to preg_replace?

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Try

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.