I have the following RegEx to parse ISIN of bonds, assets, etc.. (2 characters followed by 10 digits and characters)
([A-Z]{2})([A-Z0-9]{10})
But this also marks for example a word like this ABCDEFGHIJKL
, but this is no real ISIN. A definition of ISINs is here: WIKI
So some examples are US45256BAD38
, US64118Q1076
, XS0884410019
. What would be the correct RegEx to search for them, without matches like ABCDEFGHIJKL
?
Maybe with a RegEx to have at least one number?
If you can not use lookahead according to the Wikipedia defintion you can also just check if the last character is a number as it should be the check digit.
ISINs consist of two alphabetic characters, which are the ISO 3166-1 alpha-2 code for the issuing country, nine alpha-numeric characters (the National Securities Identifying Number, or NSIN, which identifies the security, padded as necessary with leading zeros), and one numerical check digit.
Source: https://en.wikipedia.org/wiki/International_Securities_Identification_Number#Description
Meaning this also could work:
([A-Z]{2})([A-Z0-9]{9})([0-9]{1})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With