We help IT Professionals succeed at work.
Get Started

PHP/Regex Issue with Long Strings

Gratisites asked
Last Modified: 2012-05-12
I'm parsing bbcode in a news application I'm building so my staff can easily add markup without knowing any HTML. In my testing I'm running into an issue where if the content inside a quote tag is too long (not sure of the exact byte length of the string but its only a few paragraphs, nothing extreme) the function doesn't output anything. I'm not seeing any errors, just a blank space where the parsed content should be.

If the flag is Usi and the string is long it works properly, if the flag is Usi and the string is short it blows up. The reverse is true for si.

Here's the snippet in question.

$search = array(
	$replace = array(
	        '<div class="quote">\\1</div>'
$str = preg_replace($search , $replace, $string);

Open in new window

Watch Question
Web Developer, specialising in WordPress
Most Valuable Expert 2011
This problem has been solved!
Unlock 1 Answer and 28 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE