Amber icon indicating copy to clipboard operation
Amber copied to clipboard

Support for regex and `=~` operator

Open KBeDevel opened this issue 8 months ago • 7 comments

Bash example:

line=" aaaaaab"

pattern="[[:space:]]*(a)?b"

if [[ $line =~ $pattern ]]; then
  echo "Matches"
fi

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Conditional-Constructs

Is there a way or plan to implement this with Amber?

The following code:

main (args) {
  let line = " aaaaaab"

  let pattern = "[[:space:]]*(a)?b"

  if line =~ pattern {
    echo "Matches"
  }
}

Does not compile:

 ERROR 
Identifier 'if' is a reserved keyword
at example.ab:6:3


5| 
6|   if text =~ pattern {
7|     echo "Matches"

Using Amber 0.3.3-alpha

KBeDevel avatar Jun 27 '24 23:06 KBeDevel