On Wed, Dec 11, 2013 at 10:35 AM, punit jain <contactpunitj...@gmail.com>wrote:
> > Thanks Shlomi, thats a good idea. However at the same time I was trying to > understand if something is wrong in my regex. Why would $2 capture the > number as I have used :- > > (?:(91\d{10}|0\d{10}|[7-9]\d{9}|0\d{11})|(?:(?:ph|cal)(\d+))) > > This would in my understanding match either number with regex > 91\d{10}|0\d{10}|[7-9]\d{9}|0\d{11} > or with call followed by digits. > > In my case 4 ( price for free consultation call92504060) why would $1 > store an empty string and $2 actually stores the number part ? > There are two sets of capturing parenthesis: * (91\d{10}|0\d{10}|[7-9]\d{9}|0\d{11}) = $1 * (\d+) = $2 The first set stores its match in $1 and the second set in $2. The pipe (or) does not reset the capture counter back to 1. The counter strictly goes from left to right. -- Robert Wohlfarth