why preg_match_all does not return the number of matches


Posted on 16th Feb 2014 07:03 pm by admin

My regex looks like

X[^x{4e00}-x{9fa5}]*Y

(where X and Y are two Chinese characters)

and my expression looks like

preg_match_all("/".$regex."/iu", $content, $out, PREG_PATTERN_ORDER)

it turns out that preg_match_all is always returning 1, even though count($out[0]) is > 1 (and correctly so). So I ended up using count($out[0]) rather than the value this function returns. Though this solves the current issue I need, I am very curious why this is happening. Am I misunderstanding preg_match_all?

I'd greatly appreciate if anyone can point me to the explanation of this problem. Thanks in advance!

No comments posted yet

Your Answer:

Login to answer
333 Like 22 Dislike
Previous forums Next forums
Other forums

socket communication between c++/java and sending image
hi,

i have a class in c++ called win32_sockserver which creates socket to java. i am trying

Question about GD library
I am trying to make an image that shows a random quote from my database.


However I want t

How to replace search button with link?
hi to everbody.
i have a search submit form and button like this :

<form id="f

Need Help with a query
Hello,
For some reason I am just not getting the right answer when I do this query and not quite

Problem with Subscreen
Dear Experts ,
I am facing a problem with the subscreens. My senario is as follows :

Variable Clash
In the past I've had variables clash. For example:

Code: <?php
$c = 5;
$ca

string to currency format
Hi guys...

Actually I chunk out some data from txtfile and one of the data contains amount va

tell csv import script to ignore blank rows?
Hi i have the below script but i get an error if a row is blank ie a return in the csv file at the e

Install page
How do I make it so when a user submits information on the Install page, it'll right it into the cor

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash