))#i",$markup, $out); print_r($out); Arr..." />
In your case, it's better to use preg_match with its additional parameter and parenthesis: preg_match("#((?:|>))#i",$markup, $out); print_r($out); Array ( 0 => 1 => your stuff 3 => %> ) By the way, check this online tool to debug PHP regexp, it's so useful! regex.larsolavtorvik.com EDIT : I hacked the regexp a bit so it's faster. Tested it, it works :-) Now let's explain all that stuff : preg_match will store everything he captures in the var passed as third param (here $out) if preg_match matches something, it will be store in $out0 anything that is inside () but not (?:) in the pattern will be stored in $out The patten in details : ((?:|>))#i can be viewed as ((?:|>)).((?:|>)) is capturing % then (\s*(?:^ø*)\s*?) means 0 or more spaces, then 0 or more times anything that is not the ø symbol, the 0 or more spaces Why do we use ^ø instead of .? It's because .
Is very time consuming, the regexp engine will check among all the existing characters. ^ø just check if the char is not ø. Nobody uses ø, it's an international money symbol, but if you care, you can replace it by chr(7) wich is the shell bell char that's obviously will never be typed in a web page EDIT2 : I just read your edit about capturing all the matches.
In that case, you´ll use preg_match_all the same way.
In your case, it's better to use preg_match with its additional parameter and parenthesis: preg_match("#((?:|>))#i",$markup, $out); print_r($out); Array ( 0 => 1 => your stuff 3 => %> ) By the way, check this online tool to debug PHP regexp, it's so useful! regex.larsolavtorvik.com/ EDIT : I hacked the regexp a bit so it's faster. Tested it, it works :-) Now let's explain all that stuff : preg_match will store everything he captures in the var passed as third param (here $out) if preg_match matches something, it will be store in $out0 anything that is inside () but not (?:) in the pattern will be stored in $out The patten in details : #((?:|>))#i can be viewed as ((?:|>)).((?:|>)) is capturing % then (\s*(?:^ø*)\s*?) means 0 or more spaces, then 0 or more times anything that is not the ø symbol, the 0 or more spaces.
Why do we use ^ø instead of .? It's because . Is very time consuming, the regexp engine will check among all the existing characters. ^ø just check if the char is not ø.
Nobody uses ø, it's an international money symbol, but if you care, you can replace it by chr(7) wich is the shell bell char that's obviously will never be typed in a web page. EDIT2 : I just read your edit about capturing all the matches. In that case, you´ll use preg_match_all the same way.
Result: Array ( 0 => test 1 => another test ).
Seems like it would be simpler to just use preg_match. It's often an issue with regex that parens are used both for grouping your logic and for capturing patterns. According to the PHP doc on regex syntax, The fact that plain parentheses fulfil two functions is not always helpful.
There are often times when a grouping subpattern is required without a capturing requirement. If an opening parenthesis is followed by "? :", the subpattern does not do any capturing, and is not counted when computing the number of any subsequent capturing subpatterns.
If you want to match give preg_match_all a shot with a regular expression like this: preg_match_all('/((\))/i', ' ', $result); This results in a match of just about everything under the sun. You can add/remove parens to match more/less: Array ( 0 => Array ( 0 => 1 => ) 1 => Array ( 0 => 1 => ) 2 => Array ( 0 => Array ( 0 => 1 => ) 4 => Array ( 0 => wtf 1 => sadfdsafds ) 5 => Array ( 0 => 1 => ) 6 => Array ( 0 => %> 1 => %> ) ).
One possible solution is to use the extra parens, like so, but to ditch those in the results, so you actually only use 1/2 of the total restults. This regex $matches = preg_split("/(|>)/i",$markup,-1,(PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)); for input my name is Issachere output would be Array( 0=> my name is Issac 1=>some stuff 3=>> 4=>here 5=>&;lt; 6=>more stuff 7=>> ) Which would give the desired resutls, if I only used the even numbers.
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.