user3318503
user3318503

Reputation: 3

preg_match RegExp in beginning, inside or end of word

I'm very new to this regular expression bit.

I've been trying these online services but at loss.

I need it explained to me how to write a pattern that match deroot, derooted, rooted and root anywhere in string when searching for 'root'

Upvotes: 0

Views: 214

Answers (2)

Makc
Makc

Reputation: 1132

Pattern is pretty simple:

/(root)/

You can add some modifiers i, g, m:

/(root)/i // for case-insensitive search

Upvotes: 1

aelor
aelor

Reputation: 11116

preg_match("/root/s", $input_line, $output_array);

you can use this to find any string that contains root .

demo here : http://www.phpliveregex.com/p/4v0

Upvotes: 0

Related Questions