Regular Expression - Match only 7 chars?
Posted
by Simon
on Stack Overflow
See other posts from Stack Overflow
or by Simon
Published on 2010-03-15T15:30:56Z
Indexed on
2010/03/15
15:39 UTC
Read the original article
Hit count: 271
I'm trying to match a SEDOL (exactly 7 chars: 6 alpha-numeric chars followed by 1 numeric char)
My regex
([A-Z 0-9]{6})[0-9]{1}
matches correctly but strings greater than 7 chars that begin with a valid match also match (if you see what I mean :)). For example:
B3KMJP4
matches correctly but so does:
B3KMJP4x
which shouldn't match.
Can anyone show me how to avoid this?
© Stack Overflow or respective owner