regex pattern for various number groups
I am parsing a list of code numbers, they have a pattern of 12345.1211
. They are space
delimited.
They sometimes will have a space followed by one - three addition number patterns like:
1221.121
11
or 111.111111
874.95 1211
I have a regex [0-9]+.[0-9]+
It finds a decimated number like 12345.1211
as . I encapsulate the regex with (
& )
and use 1n
to break each code with a newline.
I am using Notepad++
with find an replace. But the regex falls short with the space-included numbers.
The extra numbers endup on the same line as the next pattern.
Example of 1221.121 11
or 111.111111
874.95 1211
456.155
1221.121
11
111.111111
874.95
1211
456.155
Is there anything I can do to optionally include the extra numbers separated by a space?
Thanks.
notepad++ regex
add a comment |
I am parsing a list of code numbers, they have a pattern of 12345.1211
. They are space
delimited.
They sometimes will have a space followed by one - three addition number patterns like:
1221.121
11
or 111.111111
874.95 1211
I have a regex [0-9]+.[0-9]+
It finds a decimated number like 12345.1211
as . I encapsulate the regex with (
& )
and use 1n
to break each code with a newline.
I am using Notepad++
with find an replace. But the regex falls short with the space-included numbers.
The extra numbers endup on the same line as the next pattern.
Example of 1221.121 11
or 111.111111
874.95 1211
456.155
1221.121
11
111.111111
874.95
1211
456.155
Is there anything I can do to optionally include the extra numbers separated by a space?
Thanks.
notepad++ regex
1
The list is space delimited, yet you have codes that include spaces?
– Excellll
Feb 1 '12 at 14:28
If it is space delimited but the pattern needs to sometimes (but only sometimes) include spaces, then you will need to rigorously define when a space needs to be included and when it does not. If the definition is precise and accurate enough, then you could probably write a regex, but without that definition it isn't really possible to write one that would be 100% correct.
– EBGreen
Feb 1 '12 at 14:54
Also posting the exact regex that you are currently using will help us understand better what you are trying to do and where a fix might need to go.
– EBGreen
Feb 1 '12 at 14:57
The regex that I am using is listed, and highlighted. The list is space delimited, because it was copied from a webpage. In my example data sets, a valid CODE number shouldn't have a space in it. However my employer has made exceptions to that rule. Anytime there is a CODE number with a space, it typically has one space followed by two numbers. But there have been examples where it trailed with one or three digits. But those are even rarer.
– TheSavo
Feb 1 '12 at 16:39
I think I may have found the answer my self. If it run the regex: ([0-9]+) , which leads with a space, and trails with a space will only find a number pattern that has a space in front and behind it. Since valid Code Numbers will have a decimal, this will only find, what would be the extra digits. I wrapped it in parens, and use a back reference, lead it with an underscore, and trail it with a space. '1 ' So it will attach the extra digits to the parent, and delimit the whole string with a space. I then add and undersore to my regex pattern like so. "([0-9]+.[0-9]+) "
– TheSavo
Feb 1 '12 at 17:44
add a comment |
I am parsing a list of code numbers, they have a pattern of 12345.1211
. They are space
delimited.
They sometimes will have a space followed by one - three addition number patterns like:
1221.121
11
or 111.111111
874.95 1211
I have a regex [0-9]+.[0-9]+
It finds a decimated number like 12345.1211
as . I encapsulate the regex with (
& )
and use 1n
to break each code with a newline.
I am using Notepad++
with find an replace. But the regex falls short with the space-included numbers.
The extra numbers endup on the same line as the next pattern.
Example of 1221.121 11
or 111.111111
874.95 1211
456.155
1221.121
11
111.111111
874.95
1211
456.155
Is there anything I can do to optionally include the extra numbers separated by a space?
Thanks.
notepad++ regex
I am parsing a list of code numbers, they have a pattern of 12345.1211
. They are space
delimited.
They sometimes will have a space followed by one - three addition number patterns like:
1221.121
11
or 111.111111
874.95 1211
I have a regex [0-9]+.[0-9]+
It finds a decimated number like 12345.1211
as . I encapsulate the regex with (
& )
and use 1n
to break each code with a newline.
I am using Notepad++
with find an replace. But the regex falls short with the space-included numbers.
The extra numbers endup on the same line as the next pattern.
Example of 1221.121 11
or 111.111111
874.95 1211
456.155
1221.121
11
111.111111
874.95
1211
456.155
Is there anything I can do to optionally include the extra numbers separated by a space?
Thanks.
notepad++ regex
notepad++ regex
edited Feb 1 '12 at 16:39
TheSavo
asked Feb 1 '12 at 14:17
TheSavoTheSavo
3041313
3041313
1
The list is space delimited, yet you have codes that include spaces?
– Excellll
Feb 1 '12 at 14:28
If it is space delimited but the pattern needs to sometimes (but only sometimes) include spaces, then you will need to rigorously define when a space needs to be included and when it does not. If the definition is precise and accurate enough, then you could probably write a regex, but without that definition it isn't really possible to write one that would be 100% correct.
– EBGreen
Feb 1 '12 at 14:54
Also posting the exact regex that you are currently using will help us understand better what you are trying to do and where a fix might need to go.
– EBGreen
Feb 1 '12 at 14:57
The regex that I am using is listed, and highlighted. The list is space delimited, because it was copied from a webpage. In my example data sets, a valid CODE number shouldn't have a space in it. However my employer has made exceptions to that rule. Anytime there is a CODE number with a space, it typically has one space followed by two numbers. But there have been examples where it trailed with one or three digits. But those are even rarer.
– TheSavo
Feb 1 '12 at 16:39
I think I may have found the answer my self. If it run the regex: ([0-9]+) , which leads with a space, and trails with a space will only find a number pattern that has a space in front and behind it. Since valid Code Numbers will have a decimal, this will only find, what would be the extra digits. I wrapped it in parens, and use a back reference, lead it with an underscore, and trail it with a space. '1 ' So it will attach the extra digits to the parent, and delimit the whole string with a space. I then add and undersore to my regex pattern like so. "([0-9]+.[0-9]+) "
– TheSavo
Feb 1 '12 at 17:44
add a comment |
1
The list is space delimited, yet you have codes that include spaces?
– Excellll
Feb 1 '12 at 14:28
If it is space delimited but the pattern needs to sometimes (but only sometimes) include spaces, then you will need to rigorously define when a space needs to be included and when it does not. If the definition is precise and accurate enough, then you could probably write a regex, but without that definition it isn't really possible to write one that would be 100% correct.
– EBGreen
Feb 1 '12 at 14:54
Also posting the exact regex that you are currently using will help us understand better what you are trying to do and where a fix might need to go.
– EBGreen
Feb 1 '12 at 14:57
The regex that I am using is listed, and highlighted. The list is space delimited, because it was copied from a webpage. In my example data sets, a valid CODE number shouldn't have a space in it. However my employer has made exceptions to that rule. Anytime there is a CODE number with a space, it typically has one space followed by two numbers. But there have been examples where it trailed with one or three digits. But those are even rarer.
– TheSavo
Feb 1 '12 at 16:39
I think I may have found the answer my self. If it run the regex: ([0-9]+) , which leads with a space, and trails with a space will only find a number pattern that has a space in front and behind it. Since valid Code Numbers will have a decimal, this will only find, what would be the extra digits. I wrapped it in parens, and use a back reference, lead it with an underscore, and trail it with a space. '1 ' So it will attach the extra digits to the parent, and delimit the whole string with a space. I then add and undersore to my regex pattern like so. "([0-9]+.[0-9]+) "
– TheSavo
Feb 1 '12 at 17:44
1
1
The list is space delimited, yet you have codes that include spaces?
– Excellll
Feb 1 '12 at 14:28
The list is space delimited, yet you have codes that include spaces?
– Excellll
Feb 1 '12 at 14:28
If it is space delimited but the pattern needs to sometimes (but only sometimes) include spaces, then you will need to rigorously define when a space needs to be included and when it does not. If the definition is precise and accurate enough, then you could probably write a regex, but without that definition it isn't really possible to write one that would be 100% correct.
– EBGreen
Feb 1 '12 at 14:54
If it is space delimited but the pattern needs to sometimes (but only sometimes) include spaces, then you will need to rigorously define when a space needs to be included and when it does not. If the definition is precise and accurate enough, then you could probably write a regex, but without that definition it isn't really possible to write one that would be 100% correct.
– EBGreen
Feb 1 '12 at 14:54
Also posting the exact regex that you are currently using will help us understand better what you are trying to do and where a fix might need to go.
– EBGreen
Feb 1 '12 at 14:57
Also posting the exact regex that you are currently using will help us understand better what you are trying to do and where a fix might need to go.
– EBGreen
Feb 1 '12 at 14:57
The regex that I am using is listed, and highlighted. The list is space delimited, because it was copied from a webpage. In my example data sets, a valid CODE number shouldn't have a space in it. However my employer has made exceptions to that rule. Anytime there is a CODE number with a space, it typically has one space followed by two numbers. But there have been examples where it trailed with one or three digits. But those are even rarer.
– TheSavo
Feb 1 '12 at 16:39
The regex that I am using is listed, and highlighted. The list is space delimited, because it was copied from a webpage. In my example data sets, a valid CODE number shouldn't have a space in it. However my employer has made exceptions to that rule. Anytime there is a CODE number with a space, it typically has one space followed by two numbers. But there have been examples where it trailed with one or three digits. But those are even rarer.
– TheSavo
Feb 1 '12 at 16:39
I think I may have found the answer my self. If it run the regex: ([0-9]+) , which leads with a space, and trails with a space will only find a number pattern that has a space in front and behind it. Since valid Code Numbers will have a decimal, this will only find, what would be the extra digits. I wrapped it in parens, and use a back reference, lead it with an underscore, and trail it with a space. '1 ' So it will attach the extra digits to the parent, and delimit the whole string with a space. I then add and undersore to my regex pattern like so. "([0-9]+.[0-9]+) "
– TheSavo
Feb 1 '12 at 17:44
I think I may have found the answer my self. If it run the regex: ([0-9]+) , which leads with a space, and trails with a space will only find a number pattern that has a space in front and behind it. Since valid Code Numbers will have a decimal, this will only find, what would be the extra digits. I wrapped it in parens, and use a back reference, lead it with an underscore, and trail it with a space. '1 ' So it will attach the extra digits to the parent, and delimit the whole string with a space. I then add and undersore to my regex pattern like so. "([0-9]+.[0-9]+) "
– TheSavo
Feb 1 '12 at 17:44
add a comment |
1 Answer
1
active
oldest
votes
On your test data this regex matches all the numbers perfectly for me;
[0-9]+[.]?[0-9]+
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f384757%2fregex-pattern-for-various-number-groups%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
On your test data this regex matches all the numbers perfectly for me;
[0-9]+[.]?[0-9]+
add a comment |
On your test data this regex matches all the numbers perfectly for me;
[0-9]+[.]?[0-9]+
add a comment |
On your test data this regex matches all the numbers perfectly for me;
[0-9]+[.]?[0-9]+
On your test data this regex matches all the numbers perfectly for me;
[0-9]+[.]?[0-9]+
answered Feb 15 '13 at 11:36
woneawonea
1,48211940
1,48211940
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f384757%2fregex-pattern-for-various-number-groups%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
1
The list is space delimited, yet you have codes that include spaces?
– Excellll
Feb 1 '12 at 14:28
If it is space delimited but the pattern needs to sometimes (but only sometimes) include spaces, then you will need to rigorously define when a space needs to be included and when it does not. If the definition is precise and accurate enough, then you could probably write a regex, but without that definition it isn't really possible to write one that would be 100% correct.
– EBGreen
Feb 1 '12 at 14:54
Also posting the exact regex that you are currently using will help us understand better what you are trying to do and where a fix might need to go.
– EBGreen
Feb 1 '12 at 14:57
The regex that I am using is listed, and highlighted. The list is space delimited, because it was copied from a webpage. In my example data sets, a valid CODE number shouldn't have a space in it. However my employer has made exceptions to that rule. Anytime there is a CODE number with a space, it typically has one space followed by two numbers. But there have been examples where it trailed with one or three digits. But those are even rarer.
– TheSavo
Feb 1 '12 at 16:39
I think I may have found the answer my self. If it run the regex: ([0-9]+) , which leads with a space, and trails with a space will only find a number pattern that has a space in front and behind it. Since valid Code Numbers will have a decimal, this will only find, what would be the extra digits. I wrapped it in parens, and use a back reference, lead it with an underscore, and trail it with a space. '1 ' So it will attach the extra digits to the parent, and delimit the whole string with a space. I then add and undersore to my regex pattern like so. "([0-9]+.[0-9]+) "
– TheSavo
Feb 1 '12 at 17:44