On Jul 25, Hamish Whittal said:

>%CardType%              .1.3.6.1.4.1.45.1.6.3.3.1.1.5
>%CardSlotNum%           =calc=CardType/3.([0-9]*).0/ 

>if ( /^%([a-zA-Z]*)%[\s\t]*[\=calc\=([a-zA-Z]+)\/(.*)\/|(\.[0-9]*)]/ ) {

I'm afraid you're trying to be a bit too specific.  If you let yourself
slip into generality (match a regex, not a SPECIFIC regex), you'll find it
easier.

Your regex has a bug -- the [\=calc has a [ which starts a character
class, and then you have a closing ] at A-Z], and then you have a ) which
didn't ever get opened (since the matching ( is inside a character class.

Here's my regex:

  if (m{^%([a-z]*)%\s*=calc=([a-z]+)/([^/\\]*(?:\\.[^/\\]*)*)/}i) {
    $oid = lc $1;
    $value = $2;
    $regex = $3;
  }

Here's what my regex does:

  m{
    ^                # start of the string
    %                # '%'
    ( [a-z]* )       # 0 or more letters, captured to \1
    %                # '%'
    \s*              # 0 or more whitespace (\n, \r, \t, \f, " ")
    =calc=           # '=calc='
    ( [a-z]+ )       # 1 or more letters, captured to \2
    /                # '/'
    (                # capture the following to \3
      [^/\\]*        # 0 or more non-/ non-\ chars
      (?:
        \\. [^/\\]*  # match a \? and then 0 or more non-/ non-\ chars
      )*             # 0 or more times
    )                # (end capture of \3)
    /                # '/'
  }xi;               # /x for comments, /i for case-insensitivity

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to