0

I'm using re.search to search for the pattern of anything that might look like a credit card number in a file.

What I would like to do, is have the script then pull out the potential cc number and pass it to the Luhn algorithm for verification.

If I'm not mistaken, re.search only returns true or false. How can I pull out the cc number and set it to a variable?

Thanks.

Jason

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by cableguy414
2

re.search returns a 'match object' or None. Follow this example

>>> mo = re.search(r"b\w+", "'Give me bacon and eggs,' said the other man.")
>>> mo
<_sre.SRE_Match object at 0x7f90947e2e68>
>>> mo.group(0)
'bacon'
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.