Reputation: 43616
I want to add the symbols related to the end of the string in my regexp
echo aaa.bbb.ccc=3 | grep "aaa\.[^.]\+\.ccc=3"
I tried the following symbols but it does not works
echo aaa.bbb.ccc=3 | grep "aaa\.[^.]\+\.ccc=3\Z"
echo aaa.bbb.ccc=3 | grep "aaa\.[^.]\+\.ccc=3$/"
How I can add end of string symbol to my regexp?
Update
question 2)
echo aaa.bbb.ccc=3 | grep "aaa\.[^.]\+\.ccc=3"
# ^
# |
# What symbols I have to add here in order to say I m expecting end of string or any thing except the digits [^0-9]?
Upvotes: 1
Views: 157
Reputation: 71903
You can use
\($\|[^0-9]\)
to match either the end of input or a non-digit character.
Upvotes: 0
Reputation: 4864
Use echo aaa.bbb.ccc=3 | grep "aaa\.[^.]\+\.ccc=3$"
Answer 2:
Use echo aaa.bbb.ccc=3 | grep "aaa\.[^.]\+\.ccc=3[^0-9]*"
[^0-9]*
will include $
also.
Refer Understanding Regular Expressions for more details.
Upvotes: 3