Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write regex 'line' contains string [duplicate]

Tags:

regex

I have string:

one line
second line
magic line foo
third line

How to match full line with foo only using keyword foo?

So, I can match foo using /foo/g, but I don't know how to match full line.

Thank you for any help.

like image 652
nope123 Avatar asked Feb 12 '18 08:02

nope123


Video Answer


1 Answers

you can try this:

^.*foo.*$

it will match full line containing foo

Regex101Demo

like image 162
Rizwan M.Tuman Avatar answered Sep 18 '22 04:09

Rizwan M.Tuman