1

Trying fish, I am stuck on some bash conditionals using [[ ... ]].

It looks like [ ... ] is the usual thing, but I'm stuck on pattern and regular expression tests:

[[ "$PATH" =~ "$1" ]]
[[ $localVM =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]

How do I do those in fish?

0

1 Answer 1

3

use the string match command

if string match -q -r $pattern $var
  echo yes
else
  echo no
end

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .