Skip to content

Instantly share code, notes, and snippets.

@lengerfulluse
Created July 18, 2018 09:52
Show Gist options
  • Save lengerfulluse/e66d28344480c6545e33c61ef92dea5a to your computer and use it in GitHub Desktop.
Save lengerfulluse/e66d28344480c6545e33c61ef92dea5a to your computer and use it in GitHub Desktop.
Simple usage of python with regex and backreference
#/bin/python
# sample of python regex with non-greedy(?) and back-reference(\1).
import re
pattern = re.compile(r'paymentContractId=(.*?)">\1');
for i, line in enumerate(open('vbs-charged-backfill-orders.preprocessed')):
for match in re.finditer(pattern, line):
print match.group(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment