I want to formulate a regular expression, such that, if I pass a word,
String str = "(Living being: (cow: type (Animal) walks, motion (legs(4))) "+ "(Hen: type (bird) flies) "+ "(Caterpillar: type(worm) food(plants(green leaves)) color(green, red, yellow))"+ " (Dog: type(Animal)) )";
, the matcher group should return
and for a word
(cow: type (Animal) walks. motion (legs(4)))
, the result should be
So, for a matching word it should return complete content-set for the matching bracket. Any clues are welcome. Thanks.
(Dog: type(Animal) )
'uncle_alice' might not agree but I think one cannot do this withFor no particular reason saying 'pumping lemma' gives some folks the
regular expressions. It is easy enough to look for a closing ')' but not
so easy to skip matching pairs of '(' and ')'.