Amber
Amber copied to clipboard
Support for regex and `=~` operator
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