Regex expression for escaped quoted string won't work in php's preg_match_all?

I do not know why it doesn't work for one particular version of php, but using the idea of a non-greedy match, I came up with this string which does work.

" It non-greedily matches everything until it encounters a dbl-quote that is not preceded by an escape char. For some peculiar reason, three backslashes are needed or php complains of an unmatched bracket. I am thinking that its presence requires a backslash to precede the bracket, but I am not sure.

Can anyone confirm why three backslashes are needed? /edit whitespace limit.

I tried it on Linux Fedora PHP 5.2.6 and it seems to work fine. The output is: wally@zf ~$ php -f z. Php title="My Little Website" year="2007" description="Basic website with ..." tech="PHP, mySQL" link="test.com.

Curious, because it doesn't work on mine - Ubuntu 9.10 with PHP 5.2.10 – Scott Daniels Dec 1 '09 at 19:05.

Preg_match_all('/(\w+)\s*=\s*"((?:. *? \"?

)*)"/', $parStr, $matches, PREG_SET_ORDER); Its give me like this 1 => link 2 => test. Com Inside , everything consider as single char, for ^\\", it does not mean EXCEPT \", its mean EXCEPT \ AND EXCEPT " UPDATE for Multiple Value in Same Line preg_match_all('/(\w+)\s*=\s*"((?:^\\\*?(?:\\\")?)*? )"/', $parStr, $matches, PREG_SET_ORDER); Source String, Sample $parStr = 'title="My Little Website" year="2007" description="Basic website with ..." tech="PHP, mySQL" tech="PHP, mySQL" link="test.

Com" link="test.Com" tech="PHP, mySQL" '; Matches, Array ( 0 => Array ( 0 => title="My Little Website" 1 => title 2 => My Little Website ) 1 => Array ( 0 => year="2007" 1 => year 2 => 2007 ) 2 => Array ( 0 => description="Basic website with ..." 1 => description 2 => Basic website with ... ) 3 => Array ( 0 => tech="PHP, mySQL" 1 => tech 2 => PHP, mySQL ) 4 => Array ( 0 => tech="PHP, mySQL" 1 => tech 2 => PHP, mySQL ) 5 => Array ( 0 => link="test. Com" 1 => link 2 => test. Com ) 6 => Array ( 0 => link="test.Com" 1 => link 2 => test.

Com ) 7 => Array ( 0 => tech="PHP, mySQL" 1 => tech 2 => PHP, mySQL ) ) Personally, I feels like parsing HTML with regex, not really liked, but I don't see any other option to suggest you, so Its just a quick and dirty way. For big project or big files, I suggest you to find a real parser for that.

This code does not work when there are multiple quoted strings on a single line. It fails to find the 2nd closing quote. I think the problem is in \"?

, the? Only pertains to the ", but not the \. – Scott Daniels Dec 1 '09 at 19:03 I have added another regex – YOU Dec 2 '09 at 1:25.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions