Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with regexp.

Status
Not open for further replies.

aswolff

Programmer
Jul 31, 2006
100
US
I need a regexp that can capture the following pattern?


ABCD123451 -
ZXD12ZX -
XBXBX -

I tried the following in my perl script but it is not capturing anything.

Code:
if ($line =~ /^\s{4}w{1,10)\s-/)
{
    print "$line\n";
}

Do I need to escape the hyphen in position 15?

Thanks.
 
The regex that you included here doesn't even compile. Please try again, and repost when your regex at least compiles.

- Miller
 
w{1,10)

unless you are looking to match a literal 'w' you need a backslash in there: \w{1,10}

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top