use grep to capture regex
I have trouble capturing text like the following in input:
"xy$"
I did
grep -eo '([a-zA-Z]+)$' grep -eo '([a-zA-Z]+)\$' grep -eo '([a-zA-Z]+)\\$'
here the $ represents the literal $ no开发者_JAVA技巧t end of line.
what's wrong?You need to escape $
, so it becomes a literal
([a-zA-Z]+)\$
Try to escape the $. grep -eo '([a-ZA-Z+)\$
You need to turn on extended regexes with the -E
option:
grep -E '([a-ZA-Z]+)\$'
精彩评论