regex - How to match string (with regular expression) that begins with a string -


in bash script have match strings begin 3 times string lo; lololoba good, loloba bad, lololololoba good, balololo bad.

i tried pattern: "^$str1/{$n,}" doesn't work, how can it?

edit:

according ops comment, lololololoba bad now.

this should work:

pat="^(lo){3}" s="lolololoba" [[ $s =~ $pat ]] && echo || echo bad 

edit (as per ops comment):

if want match 3 times (i.e lolololoba , such should unmatched):

change pat="^(lo){3}" to:

pat="^(lo){3}(l[^o]|[^l].)" 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -