Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved pattern matching on strings #412

Open
CoffeeTableEspresso opened this issue Aug 20, 2021 · 3 comments
Open

Improved pattern matching on strings #412

CoffeeTableEspresso opened this issue Aug 20, 2021 · 3 comments

Comments

@CoffeeTableEspresso
Copy link
Member

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

@CoffeeTableEspresso
Copy link
Member Author

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
Copy link
Member Author

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

@CoffeeTableEspresso
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant