Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Handling of escaped plus sign ("+") in regular expressions



On 5/20/20 3:51 PM, Eric Cook wrote:
[[ +123 =~ ^\+[0-9]+$ ]]
Guessing this is the one that was excepted to return 0
in zsh [[ +123 =~ '^\+[0-9]+$' ]] would be what you wanted.

a safe way of compensate for the quoting differences of the left hand operand
is to put the ere into a variable.
pat='^\+[0-9]+$'; [[ +123 =~ $pat ]]; echo $?



Messages sorted by: Reverse Date, Date, Thread, Author