how to use Grouping regular expressions ?

A regular expression can have literal characters in it, and also zero-width positional patterns. Each literal character or positional pattern is an atom in a regular expression. You may also group several atoms together into a small regular expression that is part of a larger regular expression. One might be inclined to call such a grouping a "molecule," but normally it is also called an atom.

In older Unix-oriented tools like grep, subexpressions must be grouped with escaped parentheses, e.g. /\(Mary\)/. In Perl and most more recent tools (including egrep), grouping is done with bare parentheses, but matching a literal parenthesis requires escaping it in the pattern (the example to the side follows Perl).

asked Sep 13, 2013 in Regular-exp by rajesh
edited Sep 12, 2013
0 votes

1 Answer

0 votes
/(Raju)( )(had)/ 

Raju had a little lamb.
And everywhere that Mary
went, the lamb was sure
to go.
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013