Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How anchor to line end in regex

10 views
Skip to first unread message

Budi

unread,
Aug 22, 2020, 10:13:50 PM8/22/20
to bug-...@gnu.org
How anchor to line end in bash regex [[ ]]
h=hi
[[ $h =~ ^hi\$ ]] && echo Yes

cannot work, or is it bug yet

Lawrence Velázquez

unread,
Aug 22, 2020, 10:40:56 PM8/22/20
to Budi, bug-...@gnu.org
Hi,
Special characters are matched literally if they are quoted, so you
just have to make sure the $ is not quoted.

$ h=hi
$ [[ $h =~ ^hi\$ ]] && echo Yes
$ [[ $h =~ ^hi$ ]] && echo Yes
Yes

vq
0 new messages