RegEx for ISIN with at least 1 number
I have the following RegEx to parse ISIN of fonds, 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?
regex
add a comment |
I have the following RegEx to parse ISIN of fonds, 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?
regex
add a comment |
I have the following RegEx to parse ISIN of fonds, 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?
regex
I have the following RegEx to parse ISIN of fonds, 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?
regex
regex
asked Oct 16 '15 at 7:23
ZerOneZerOne
77731028
77731028
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can use a lookahead regex:
b([A-Z]{2})((?![A-Z]{10}b)[A-Z0-9]{10})b
RegEx Demo
(?![A-Z]{10}b)
is a negative lookahead that will fail the match if all 10 chars are letters after first 2 chars.
Thanks! This works fine in the demo, but I use it in PLSQL with REGEXP_SUBSTR and there it fails.. do you know if REGEXP_SUBSTR does not support lookaheads?
– ZerOne
Oct 16 '15 at 8:15
Hmm you didn't mention this in question. I'm not sure if Oracle regex supports lookahead. Check documentation.
– anubhava
Oct 16 '15 at 8:36
1
Yes I thought that this would be no problem for Oracle, but in fact Oracle doesn't support lookahead and lookbehind. You answered my question so thanks! I just asked the wrong question
– ZerOne
Oct 16 '15 at 10:03
add a comment |
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})
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33164718%2fregex-for-isin-with-at-least-1-number%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use a lookahead regex:
b([A-Z]{2})((?![A-Z]{10}b)[A-Z0-9]{10})b
RegEx Demo
(?![A-Z]{10}b)
is a negative lookahead that will fail the match if all 10 chars are letters after first 2 chars.
Thanks! This works fine in the demo, but I use it in PLSQL with REGEXP_SUBSTR and there it fails.. do you know if REGEXP_SUBSTR does not support lookaheads?
– ZerOne
Oct 16 '15 at 8:15
Hmm you didn't mention this in question. I'm not sure if Oracle regex supports lookahead. Check documentation.
– anubhava
Oct 16 '15 at 8:36
1
Yes I thought that this would be no problem for Oracle, but in fact Oracle doesn't support lookahead and lookbehind. You answered my question so thanks! I just asked the wrong question
– ZerOne
Oct 16 '15 at 10:03
add a comment |
You can use a lookahead regex:
b([A-Z]{2})((?![A-Z]{10}b)[A-Z0-9]{10})b
RegEx Demo
(?![A-Z]{10}b)
is a negative lookahead that will fail the match if all 10 chars are letters after first 2 chars.
Thanks! This works fine in the demo, but I use it in PLSQL with REGEXP_SUBSTR and there it fails.. do you know if REGEXP_SUBSTR does not support lookaheads?
– ZerOne
Oct 16 '15 at 8:15
Hmm you didn't mention this in question. I'm not sure if Oracle regex supports lookahead. Check documentation.
– anubhava
Oct 16 '15 at 8:36
1
Yes I thought that this would be no problem for Oracle, but in fact Oracle doesn't support lookahead and lookbehind. You answered my question so thanks! I just asked the wrong question
– ZerOne
Oct 16 '15 at 10:03
add a comment |
You can use a lookahead regex:
b([A-Z]{2})((?![A-Z]{10}b)[A-Z0-9]{10})b
RegEx Demo
(?![A-Z]{10}b)
is a negative lookahead that will fail the match if all 10 chars are letters after first 2 chars.
You can use a lookahead regex:
b([A-Z]{2})((?![A-Z]{10}b)[A-Z0-9]{10})b
RegEx Demo
(?![A-Z]{10}b)
is a negative lookahead that will fail the match if all 10 chars are letters after first 2 chars.
answered Oct 16 '15 at 7:29
anubhavaanubhava
533k48331408
533k48331408
Thanks! This works fine in the demo, but I use it in PLSQL with REGEXP_SUBSTR and there it fails.. do you know if REGEXP_SUBSTR does not support lookaheads?
– ZerOne
Oct 16 '15 at 8:15
Hmm you didn't mention this in question. I'm not sure if Oracle regex supports lookahead. Check documentation.
– anubhava
Oct 16 '15 at 8:36
1
Yes I thought that this would be no problem for Oracle, but in fact Oracle doesn't support lookahead and lookbehind. You answered my question so thanks! I just asked the wrong question
– ZerOne
Oct 16 '15 at 10:03
add a comment |
Thanks! This works fine in the demo, but I use it in PLSQL with REGEXP_SUBSTR and there it fails.. do you know if REGEXP_SUBSTR does not support lookaheads?
– ZerOne
Oct 16 '15 at 8:15
Hmm you didn't mention this in question. I'm not sure if Oracle regex supports lookahead. Check documentation.
– anubhava
Oct 16 '15 at 8:36
1
Yes I thought that this would be no problem for Oracle, but in fact Oracle doesn't support lookahead and lookbehind. You answered my question so thanks! I just asked the wrong question
– ZerOne
Oct 16 '15 at 10:03
Thanks! This works fine in the demo, but I use it in PLSQL with REGEXP_SUBSTR and there it fails.. do you know if REGEXP_SUBSTR does not support lookaheads?
– ZerOne
Oct 16 '15 at 8:15
Thanks! This works fine in the demo, but I use it in PLSQL with REGEXP_SUBSTR and there it fails.. do you know if REGEXP_SUBSTR does not support lookaheads?
– ZerOne
Oct 16 '15 at 8:15
Hmm you didn't mention this in question. I'm not sure if Oracle regex supports lookahead. Check documentation.
– anubhava
Oct 16 '15 at 8:36
Hmm you didn't mention this in question. I'm not sure if Oracle regex supports lookahead. Check documentation.
– anubhava
Oct 16 '15 at 8:36
1
1
Yes I thought that this would be no problem for Oracle, but in fact Oracle doesn't support lookahead and lookbehind. You answered my question so thanks! I just asked the wrong question
– ZerOne
Oct 16 '15 at 10:03
Yes I thought that this would be no problem for Oracle, but in fact Oracle doesn't support lookahead and lookbehind. You answered my question so thanks! I just asked the wrong question
– ZerOne
Oct 16 '15 at 10:03
add a comment |
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})
add a comment |
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})
add a comment |
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 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})
answered Nov 21 '18 at 17:06
J. PeterJ. Peter
5112
5112
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33164718%2fregex-for-isin-with-at-least-1-number%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown