yasl icon indicating copy to clipboard operation
yasl copied to clipboard

Improved pattern matching on strings

Open CoffeeTableEspresso opened this issue 3 years ago • 3 comments

glob like syntax for this is probably sufficient, rather than full regex

CoffeeTableEspresso avatar Aug 20 '21 21:08 CoffeeTableEspresso

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.

CoffeeTableEspresso avatar Feb 10 '22 04:02 CoffeeTableEspresso

The best way to do this is probably to use "..." for the patterns described here, and '...' for the literal strings that exist already.

CoffeeTableEspresso avatar Feb 10 '22 04:02 CoffeeTableEspresso

Also consider using alternate syntax here: _ vs ?, % vs *, and ! vs ^.

CoffeeTableEspresso avatar Feb 10 '22 04:02 CoffeeTableEspresso