yasl
yasl copied to clipboard
Improved pattern matching on strings
glob
like syntax for this is probably sufficient, rather than full regex
Stuff like the following should be allowed:
match dir {
"forward #{let v}" {
pos += v->toint()
}
...
}
As well as glob like syntax:
-
*
matches any number of characters, so*.txt
matches any string ending in.txt
. -
?
matches any single character, so?.txt
matches any string that is exactly one character followed by.txt
. -
[abc]
matches a single character from withing the brackets. -
[^abc]
matches a single character not within the brackets. -
[a-z]
matches a single character from the range described in the brackets. -
[^a-z]
matches a single character from outside the range described in the brackets.
The best way to do this is probably to use "..."
for the patterns described here, and '...'
for the literal strings that exist already.
Also consider using alternate syntax here: _
vs ?
, %
vs *
, and !
vs ^
.