Welcome Guest, Not a member yet? Register   Sign In
preg_match() fails?
#1

[eluser]bookworm[/eluser]
very strange...

look, i have data:
Code:
$str = ".....long string....<tag>....very long string....</tag>....long string....";

long string means about 5000-10000 chars.
very long string - about 20000 chars.

Ok.

Than, I want to extract some data:

Code:
$arr = array();
preg_match("/<tag>((.|\\n|\\r)+?)<\\/tag>/", $str, $arr);

If I will execute php cli, or my php file via web site - it's OK!
but if this code inside codeigniers' controller file...

it fails on long strings! when data between <tag> and </tag> is about 15000 chars...
why?


and more!


this:

Code:
preg_match("/<tag>((.|\\n|\\r)+)<\\/tag>/", $str, $arr);

without "?" after "+" will fail even on short strings in codeigniter!

any ideas, guys?
#2

[eluser]bookworm[/eluser]
Oh! ereg_match is ok! But it's depricated! Sad
#3

[eluser]BrianDHall[/eluser]
Only because it will be removed in PHP 6, which I've yet to hear a good thing about and which is likely years away from being into live production sites. So for now, no worries.

Not that it wouldn't be nice to know why it doesn't work with preg as it is supposed to be faster, but I haven't a clue.




Theme © iAndrew 2016 - Forum software by © MyBB