sanket vaidya wrote:
From: Manasi Bopardikar [mailto:[EMAIL PROTECTED]
Hi,
I have a regex --- $array[3]=~/[M|T|W|TR|F]\s[M|T|W|TR|F]\s(.*?)/;
I want to extract the value of expression highlighted in red.Is there any
way to do it.
You want to capture character "?" means zero or one time repetition.
Only if it follows a non-metacharacter. In the OP's case it follows the
quantifier * which changes it to a non-greedy quantifier.
To disable the effect of such characters use \Q & to enable the effect use \E.
So try $array[3]=~/[M|T|W|TR|F]\s[M|T|W|TR|F]\s(.*\Q?\E)/;
Or just put a backslash in front of it:
$array[3]=~/[M|T|W|TR|F]\s[M|T|W|TR|F]\s(.*\?)/;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/