Skip to content

Instantly share code, notes, and snippets.

@vito
Created January 18, 2011 05:26
Show Gist options
  • Save vito/784020 to your computer and use it in GitHub Desktop.
Save vito/784020 to your computer and use it in GitHub Desktop.
regex planning
"123-456-hello" case-of: {
/(\d+)-(\d+)-(?<foo>\w+)/ ->
{ \0 print -- prints 123-456-hello
\1 print -- prints 123
foo print -- prints hello (\2 available too?)
} call
}
"123-456-hello" replace: /(\d+)-(?<foo>\w+)/ with: {
foo .. "-" .. \1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment