kspaeth
kspaeth

Reputation: 31

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" V.I.D.C.A.M. It is embedded between a bunch of periods and includes periods which is really screwing me up, here is an example:

E..)..@[email protected]...$[......TP..P<........SMBs......................................NTLMSSP.........0.........`b.m..........L.L.<...V.I.D.C.A.M.....V.I.D.C.A.M.....V.I.D.C.A.M.....V.I.D.C.A.M.....V.I.D.C.A.M..............W.i.n.d.o.w.s. .5...1...W.i.n.d.o.w.s. .2.0.0.0. .L.A.N. .M.a.n.a.g.e.r..

How do you handle something like that?

Upvotes: 0

Views: 250

Answers (1)

Joe Casadonte
Joe Casadonte

Reputation: 16859

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.})

Upvotes: 3

Related Questions