Regex problem in perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ankur2007
    New Member
    • Jun 2007
    • 1

    Regex problem in perl

    I don't understand why wouldn't this regex :

    if(m/\s+([\w+\+-])\s+\/\s+\+\s+\w+\s+\ w+\s+\w+\s+\w+$/)

    match the second NA


    in this string (all in one line):

    NA hsa-mir-129-1 hsa-mir-129-1 Targets No Relationship to Gene 7 NA / + NA NA 127635160 127635232
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    Your problem is with this "([\w+\+-])"

    You should probably read up on regular expression from perldoc:
    perldoc perlrequick

    However, this would work as a replacement: (?:\w|\-)+

    - Miller

    Comment

    • savanm
      New Member
      • Oct 2006
      • 85

      #3
      hi try this

      if(m/\s+([\w]+)\+-\s+\/\s+\+\s+\w+\s+\ w+\s+\w+\s+\w+$/)

      Comment

      Working...