[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How anchor to line end in regex
From: |
Lawrence Velázquez |
Subject: |
Re: How anchor to line end in regex |
Date: |
Sat, 22 Aug 2020 22:40:48 -0400 |
Hi,
> On Aug 22, 2020, at 10:13 PM, Budi <budikusasi@gmail.com> wrote:
>
> How anchor to line end in bash regex [[ ]]
> h=hi
> [[ $h =~ ^hi\$ ]] && echo Yes
>
> cannot work, or is it bug yet
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