zattz
asked on
Extract text
Hi
How can I best extract in c# using a regex an 8 digit mix of numbers and letters? possibly with spaces between
Thanks
How can I best extract in c# using a regex an 8 digit mix of numbers and letters? possibly with spaces between
Thanks
ASKER
Hi
Having a bit of a problem with this, the string will always contain a mix of both numbers and letters. At the moment the regex is picking up strings with just letters.
Having a bit of a problem with this, the string will always contain a mix of both numbers and letters. At the moment the regex is picking up strings with just letters.
The "\d" in the pattern should account for numbers. Can you provide some sample inputs?
ASKER
The matches should be a mix including BOTH numbers and letters.
I have a large body of text, and "whatsapp" is being returned. This does not include both numbers and letters, and so should not match.
I have a large body of text, and "whatsapp" is being returned. This does not include both numbers and letters, and so should not match.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually, I need to revise the above to account for the spaces. Uno momento.
Updated:
\b(?=[ \d]*[a-zA-Z])(?=[ a-zA-Z]*\d)(?: *[a-zA-Z\d]){8}\b
ASKER
The last solution that deals with spaces picked up "february", but never mind, the example above is working fine and I don't think I will see any spaces. Thank you so much for the help! I appreciate it
Open in new window