Regex with grep - match unknown number of alphabetical characters? -
i searching like:
stringone_****_******_stringtwo where know stringone , stringtwo. * reflect unknown number of letters (capital), however.
i had been under assumption
grep -nr "stringone_\w+_\w+_stringtwo" . would work, not finding matches.
how can formulate regex correctly (using grep in cygwin)?
have @ manual. without -e flag, grep assumes "basic" regular expressions. in case meta-characters lose special meaning, unless escape them. do
grep -nr "stringone_\w\+_\w\+_stringtwo" or
grep -nre "stringone_\w+_\w+_stringtwo" or, since want uppercase letters:
grep -nr "stringone_[a-z]\+_[a-z]\+_stringtwo" grep -nre "stringone_[a-z]+_[a-z]+_stringtwo" otherwise, strings 3 or more components in middle accepted.
Comments
Post a Comment