Link to home
Start Free TrialLog in
Avatar of ncw
ncw

asked on

Php preg_match_all for pattern matching

I've used the code below to find matches for [sometextXX] where XX is a numeric. What code do I need to find similar matches where XX is a string which varies, and return the whole string including the brackets and also separately return the XX string in the $matches array?  
<?php
$sourcestring="your source string";
preg_match_all('~\[sometext(\d+)\]~',$sourcestring,$matches);
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ncw
ncw

ASKER

Thanks very much.