prafull has asked for the wisdom of the Perl Monks concerning the following question:

Hi All ,

I need ur help in following pattern.

I have one key like

$key = qq{'5.I.(f2401)' ? '5.I.(f2401)' : '3.I.(f2400)'};

from this key I want to get 5 ( from 5.I) and 3 from (3.I)


Regards
Prafull

Replies are listed 'Best First'.
Re: Reg exp issue
by roboticus (Chancellor) on Dec 15, 2010 at 13:18 UTC

    prafull:

    What have you tried? What error(s) did you get?

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: Reg exp issue
by ww (Archbishop) on Dec 15, 2010 at 13:35 UTC

    You want to get "5 ( from 5.I) and 3 from (3.I)" from which 5.I?

    $key = qq{'5.I.(f2401)' ? '5.I.(f2401)' : '3.I.(f2400)'};

    This one       ^   or this one         ^   ?

      Thanx a lot everyone for sharing knowledge.

      ww,
      I want 5.I from both.

      Regards
      Prafull
Re: Reg exp issue
by Anonymous Monk on Dec 15, 2010 at 13:19 UTC
      use YAPE::Regex::Explain; print YAPE::Regex::Explain->new( qr/'\.(\d+)\.I\./ )->explain; __END__ The regular expression: (?-imsx:'\.(\d+)\.I\.) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ' '\'' ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- \d+ digits (0-9) (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- I 'I' ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------