How to write regex 'line' contains string

40.5k views Asked by At

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.

1

There are 1 answers

0
Mustofa Rizwan On BEST ANSWER

you can try this:

^.*foo.*$

it will match full line containing foo

Regex101Demo