简体   繁体   中英

Regex Match “words” That Contain Periods perl

I am going through a TCPDUMP file (in .txt format) and trying to pull out any line that contains the use of the "word" VIDCAM It is embedded between a bunch of periods and includes periods which is really screwing me up, here is an example:

E..)..@.@.8Q...obr.f...$[......TP..P<........SMBs......................................NTLMSSP.........0.........`bm.........LL<...VIDCAM....VIDCAM....VIDCAM....VIDCAM....VIDCAM.............Windows .5...1...Windows .2.0.0.0. .LAN .Manager.

How do you handle something like that?

You need to escape the periods:

if ($string =~ m{V\.I\.D\.C\.A\.M\.}) {
    ...
}

or if your string is entirely quoted, use the \\Q which escapes any metacharacters that follow.

if ($string =~ m{\QV.I.D.C.A.M.})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM