views:

82

answers:

2

I want to parse this

(adv) much (thanks)

I want to eliminate the words and the bracket (adv) but not (thanks)

the condition is: inside bracket, and word length inside bracket is 1-5 characters

I am using preg_match in PHP

Thank You

+2  A: 
$matches = NULL;
preg_match("/\([^\)]{1,5}\)/", "(adv) much (thanks)", $matches);
var_export($matches);
array (
 0 => '(adv)',
)
Matthew Flaschen
how about (adv) (n) much (thanks)I want to select (adv) and (n)...I tried it and it works!I love stackoverflowThanks!
bn
+2  A: 
$str = '(adv) much (thanks)';
$str = preg_replace('/\(\w{1,5}\) ?/', '', $str);
Jason Weathered