Skip to content

Instantly share code, notes, and snippets.

@Descent098
Created May 5, 2022 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Descent098/ca2b3408101525c8538978d442a02cea to your computer and use it in GitHub Desktop.
Save Descent098/ca2b3408101525c8538978d442a02cea to your computer and use it in GitHub Desktop.
Useful regex expressions

Quoting

Terms inside single quotes: (?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*' Terms inside double quotes: (?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"

Operators

Finds (not content seperated by them though) * / + - / < > <= >= % = /=: (\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=|%)

Finds True or False (and uncapitalized): (true|false|True|False)

Finds eq ne lt le gt ge not and or eqv neqv: (eq|ne|lt|le|gt|ge|not|and|or|eqv|neqv)

finds < > <= >= == || | && ^ & << >>: (&&|\|\||<=|>=|>>|<<|<|>|==|\/=|=|\||\^|&)

Punctuation

Finds (not other content though) ( ) [ ] , : & % ; . ! ?: [()\[\],:&%;.!?]

Numbers

Integers: \d+(?![.e])(_[a-z]\w+)? Floats (with or without prefix): [+-]?\d*\.\d+([ed][-+]?\d+)?(_[a-z]\w+)? Floats w/prefix (number before .): [+-]?\d+\.\d*([ed][-+]?\d+)?(_[a-z]\w+)?

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