Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16793

Re: How anchor to line end in regex

From Lawrence Velázquez <vq@larryv.me>
Newsgroups gnu.bash.bug
Subject Re: How anchor to line end in regex
Date 2020-08-22 22:40 -0400
Message-ID <mailman.829.1598150455.2469.bug-bash@gnu.org> (permalink)
References <CAH0GyZC85DZkUcwOMeuATvCF27O_N-4q+PKAPvaC5TxYvuVPcg@mail.gmail.com> <B1E98D8D-A2FB-48E9-9EA0-1198FF887038@larryv.me>

Show all headers | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: How anchor to line end in regex Lawrence Velázquez <vq@larryv.me> - 2020-08-22 22:40 -0400

csiph-web