Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

regex in perl

by noviceuser (Acolyte)
on Oct 21, 2021 at 09:41 UTC ( [id://11137842]=perlquestion: print w/replies, xml ) Need Help??

noviceuser has asked for the wisdom of the Perl Monks concerning the following question:

suppose i have multiple lines like below and i want to grep lines having "code" only after fixed pattern "/dir1/dir2/100.10/dir3/100.20/" . i have tried using grep "/code/",but it is giving all the lines containing the match elsewhere. please help

/dir1/dir2/100.10/dir3/100.20/code/abc/def.txt /dir1/dir2/100.10/dir3/100.20/code/def/ghi.txt . .

Replies are listed 'Best First'.
Re: regex in perl
by Corion (Patriarch) on Oct 21, 2021 at 09:56 UTC

    What prevents you from grepping for /dir1/dir2/100.10/dir3/100.20/code then?

Re: regex in perl
by perlfan (Vicar) on Oct 22, 2021 at 18:17 UTC
    It's doing exactly what you're telling it to do since code (heh) is in the examples you. grep works conceptionally the same way as the utility, so you need to define a regexp that's sufficiently selective.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11137842]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 22:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found