Python for (Nuke) Compers 0x12 - Regexes
Other resources
Regexes are pretty well known, if what i’m handwaving at is of interest, here’s some other places to read:
- Wikipedia - https://en.wikipedia.org/wiki/Regular_expression
- Regex101 - super handy tester - https://regex101.com/
- Python 3’s docs - https://docs.python.org/3/howto/regex.html
- Zetcode! Zetcode’s awesome - https://zetcode.com/python/regularexpressions/
My demo rig
here’s the nukescript (7kb)
that cheat sheet i was writing up
positional anchor
^ start of text
$ end of text
wildcard
. literally whatever
how many? (aka: quantifiers)
+ 1 or more (of the thing before it)
* 0 or more (of the thing before it)
? 0 or 1 (of the thing before it)
groups
(aaa|bbb|ccc) aaa OR bbb OR ccc
classes
[abc] anything in the class 'abc' (so basically, a or b or c)
[^abc] anything OTHER than class 'abc' (so basically, a or b or c)
shortcuts
[a-z] all lowercase
[A-Z] all uppercase
[0-9] all numbers