Remove numbers that contains 8-10 digits at different places in a lineRegular expression to match a line that doesn't contain a wordConverting user input string to regular expressionRemoving empty lines in Notepad++Regex: Remove lines containingRegEx to extract the first 6 to 10 digit number, excluding 8 digit numbersRegex - searching for a certain number of digits in each lineR remove repeated digit sequencesRegex - Remove all but 2 digitsExpression to search for a 10 digit specific numberRemove a 4- to 6-digit number from an alphanumeric string
How to slow yourself down (for playing nice with others)
LocalDate.plus Incorrect Answer
Why does increasing the sampling rate make implementing an anti-aliasing filter easier?
Will change of address affect direct deposit?
Washer drain pipe overflow
How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?
What food production methods would allow a metropolis like New York to become self sufficient
How do I get past a 3-year ban from overstay with VWP?
What's the best way to update Homebrew when upgrading macOS?
Why does the Earth follow an elliptical trajectory rather than a parabolic one?
Make all the squares explode
How to make a Lich look like a human without magic in 5e?
"Right on the tip of my tongue" meaning?
International Code of Ethics for order of co-authors in research papers
What is the best way for a skeleton to impersonate human without using magic?
Showing that HALF-2-SAT is in P
Ubuntu won't let me edit or delete .vimrc file
expl3-strategy to automatically update the title of a document, depending on its content
Ex-manager wants to stay in touch, I don't want to
Is Simic Ascendancy triggered by Awakening of Vitu-Ghazi?
Why in a Ethernet LAN, a packet sniffer can obtain all packets sent over the LAN?
Is there a need for better software for writers?
Unit Test - Testing API Methods
How does Howard Stark know this?
Remove numbers that contains 8-10 digits at different places in a line
Regular expression to match a line that doesn't contain a wordConverting user input string to regular expressionRemoving empty lines in Notepad++Regex: Remove lines containingRegEx to extract the first 6 to 10 digit number, excluding 8 digit numbersRegex - searching for a certain number of digits in each lineR remove repeated digit sequencesRegex - Remove all but 2 digitsExpression to search for a 10 digit specific numberRemove a 4- to 6-digit number from an alphanumeric string
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a list of different items. Some of them have 8-10 digits in front of the name, some others have these 8-10 digits behind the name and some others again don't have these numbers in the name.
I have two expressions that I use to remove these digits, but I can not manage to combine them with | (or). They work each for themselves, but if I use the first expression first, then the second expression, I don't get the result I want to have.
I use these to expressions for now:
(?<=[d]8,10) (.*)
.*?(?=[d]8,10)
But if I use them both (first one and then the other), then some of the lines become totally empty.
How can I combine these to to do what I want, or if it's better, write a new expression that does what I want to do :)
List is like this:
12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145
Want this result:
Book
Book
Book
Book
Cabinet 120x30x145
regex
add a comment |
I have a list of different items. Some of them have 8-10 digits in front of the name, some others have these 8-10 digits behind the name and some others again don't have these numbers in the name.
I have two expressions that I use to remove these digits, but I can not manage to combine them with | (or). They work each for themselves, but if I use the first expression first, then the second expression, I don't get the result I want to have.
I use these to expressions for now:
(?<=[d]8,10) (.*)
.*?(?=[d]8,10)
But if I use them both (first one and then the other), then some of the lines become totally empty.
How can I combine these to to do what I want, or if it's better, write a new expression that does what I want to do :)
List is like this:
12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145
Want this result:
Book
Book
Book
Book
Cabinet 120x30x145
regex
2
What regex flavor are you using (i.e. which tool) and how do you apply it? Just getting a regex to match does not remove text, so please make a Minimal, Complete, and Verifiable example to demonstrate.
– Yunnosch
Mar 23 at 10:56
1
Why not replacebd8,10bwith nothing?
– Toto
Mar 23 at 11:00
add a comment |
I have a list of different items. Some of them have 8-10 digits in front of the name, some others have these 8-10 digits behind the name and some others again don't have these numbers in the name.
I have two expressions that I use to remove these digits, but I can not manage to combine them with | (or). They work each for themselves, but if I use the first expression first, then the second expression, I don't get the result I want to have.
I use these to expressions for now:
(?<=[d]8,10) (.*)
.*?(?=[d]8,10)
But if I use them both (first one and then the other), then some of the lines become totally empty.
How can I combine these to to do what I want, or if it's better, write a new expression that does what I want to do :)
List is like this:
12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145
Want this result:
Book
Book
Book
Book
Cabinet 120x30x145
regex
I have a list of different items. Some of them have 8-10 digits in front of the name, some others have these 8-10 digits behind the name and some others again don't have these numbers in the name.
I have two expressions that I use to remove these digits, but I can not manage to combine them with | (or). They work each for themselves, but if I use the first expression first, then the second expression, I don't get the result I want to have.
I use these to expressions for now:
(?<=[d]8,10) (.*)
.*?(?=[d]8,10)
But if I use them both (first one and then the other), then some of the lines become totally empty.
How can I combine these to to do what I want, or if it's better, write a new expression that does what I want to do :)
List is like this:
12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145
Want this result:
Book
Book
Book
Book
Cabinet 120x30x145
regex
regex
edited Mar 23 at 11:08
revo
34.9k135289
34.9k135289
asked Mar 23 at 10:49
user10094121user10094121
124
124
2
What regex flavor are you using (i.e. which tool) and how do you apply it? Just getting a regex to match does not remove text, so please make a Minimal, Complete, and Verifiable example to demonstrate.
– Yunnosch
Mar 23 at 10:56
1
Why not replacebd8,10bwith nothing?
– Toto
Mar 23 at 11:00
add a comment |
2
What regex flavor are you using (i.e. which tool) and how do you apply it? Just getting a regex to match does not remove text, so please make a Minimal, Complete, and Verifiable example to demonstrate.
– Yunnosch
Mar 23 at 10:56
1
Why not replacebd8,10bwith nothing?
– Toto
Mar 23 at 11:00
2
2
What regex flavor are you using (i.e. which tool) and how do you apply it? Just getting a regex to match does not remove text, so please make a Minimal, Complete, and Verifiable example to demonstrate.
– Yunnosch
Mar 23 at 10:56
What regex flavor are you using (i.e. which tool) and how do you apply it? Just getting a regex to match does not remove text, so please make a Minimal, Complete, and Verifiable example to demonstrate.
– Yunnosch
Mar 23 at 10:56
1
1
Why not replace
bd8,10b with nothing?– Toto
Mar 23 at 11:00
Why not replace
bd8,10b with nothing?– Toto
Mar 23 at 11:00
add a comment |
3 Answers
3
active
oldest
votes
Why not just use the following.
Check if there are 8 numbers in the beginning of the string, or at the end of it and remove them.
(^d8,10s*|s*d8,10$)
It gives the wanted behaviour
add a comment |
Instead of only matching everything but a number containing
8-10 digits + adjacent spaces, use a regex to substitute
such a number (also + adjacent spaces) with an empty string.
To match, use the following regex:
*d8,10 *
That is:
*- a space and an asterix - a sequence of spaces (may be empty),d8,10- a sequence of 8 to 10 digits,*- another sequence of spaces (may be empty).
The replacement string is (as I said) empty. Of course, you should useg (global) option.
Note that you can not use s instead of the space, as s matches alsoCR and LF and we don't want this.
For a working example see https://regex101.com/r/1hsGzT/1
add a comment |
You need to use b meta sequence boundary:
/b[0-9s]8,10b/g;
var str = `12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145`;
var rgx = /b[0-9s]8,10b/g;
var res = str.replace(rgx, `n`)
console.log(res);
This will remove123 456
– Toto
Mar 23 at 11:31
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%2f55312915%2fremove-numbers-that-contains-8-10-digits-at-different-places-in-a-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Why not just use the following.
Check if there are 8 numbers in the beginning of the string, or at the end of it and remove them.
(^d8,10s*|s*d8,10$)
It gives the wanted behaviour
add a comment |
Why not just use the following.
Check if there are 8 numbers in the beginning of the string, or at the end of it and remove them.
(^d8,10s*|s*d8,10$)
It gives the wanted behaviour
add a comment |
Why not just use the following.
Check if there are 8 numbers in the beginning of the string, or at the end of it and remove them.
(^d8,10s*|s*d8,10$)
It gives the wanted behaviour
Why not just use the following.
Check if there are 8 numbers in the beginning of the string, or at the end of it and remove them.
(^d8,10s*|s*d8,10$)
It gives the wanted behaviour
answered Mar 23 at 11:03
Yassin HajajYassin Hajaj
14.8k73062
14.8k73062
add a comment |
add a comment |
Instead of only matching everything but a number containing
8-10 digits + adjacent spaces, use a regex to substitute
such a number (also + adjacent spaces) with an empty string.
To match, use the following regex:
*d8,10 *
That is:
*- a space and an asterix - a sequence of spaces (may be empty),d8,10- a sequence of 8 to 10 digits,*- another sequence of spaces (may be empty).
The replacement string is (as I said) empty. Of course, you should useg (global) option.
Note that you can not use s instead of the space, as s matches alsoCR and LF and we don't want this.
For a working example see https://regex101.com/r/1hsGzT/1
add a comment |
Instead of only matching everything but a number containing
8-10 digits + adjacent spaces, use a regex to substitute
such a number (also + adjacent spaces) with an empty string.
To match, use the following regex:
*d8,10 *
That is:
*- a space and an asterix - a sequence of spaces (may be empty),d8,10- a sequence of 8 to 10 digits,*- another sequence of spaces (may be empty).
The replacement string is (as I said) empty. Of course, you should useg (global) option.
Note that you can not use s instead of the space, as s matches alsoCR and LF and we don't want this.
For a working example see https://regex101.com/r/1hsGzT/1
add a comment |
Instead of only matching everything but a number containing
8-10 digits + adjacent spaces, use a regex to substitute
such a number (also + adjacent spaces) with an empty string.
To match, use the following regex:
*d8,10 *
That is:
*- a space and an asterix - a sequence of spaces (may be empty),d8,10- a sequence of 8 to 10 digits,*- another sequence of spaces (may be empty).
The replacement string is (as I said) empty. Of course, you should useg (global) option.
Note that you can not use s instead of the space, as s matches alsoCR and LF and we don't want this.
For a working example see https://regex101.com/r/1hsGzT/1
Instead of only matching everything but a number containing
8-10 digits + adjacent spaces, use a regex to substitute
such a number (also + adjacent spaces) with an empty string.
To match, use the following regex:
*d8,10 *
That is:
*- a space and an asterix - a sequence of spaces (may be empty),d8,10- a sequence of 8 to 10 digits,*- another sequence of spaces (may be empty).
The replacement string is (as I said) empty. Of course, you should useg (global) option.
Note that you can not use s instead of the space, as s matches alsoCR and LF and we don't want this.
For a working example see https://regex101.com/r/1hsGzT/1
edited Mar 23 at 12:08
The fourth bird
28.3k91631
28.3k91631
answered Mar 23 at 11:11
Valdi_BoValdi_Bo
5,8502916
5,8502916
add a comment |
add a comment |
You need to use b meta sequence boundary:
/b[0-9s]8,10b/g;
var str = `12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145`;
var rgx = /b[0-9s]8,10b/g;
var res = str.replace(rgx, `n`)
console.log(res);
This will remove123 456
– Toto
Mar 23 at 11:31
add a comment |
You need to use b meta sequence boundary:
/b[0-9s]8,10b/g;
var str = `12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145`;
var rgx = /b[0-9s]8,10b/g;
var res = str.replace(rgx, `n`)
console.log(res);
This will remove123 456
– Toto
Mar 23 at 11:31
add a comment |
You need to use b meta sequence boundary:
/b[0-9s]8,10b/g;
var str = `12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145`;
var rgx = /b[0-9s]8,10b/g;
var res = str.replace(rgx, `n`)
console.log(res);You need to use b meta sequence boundary:
/b[0-9s]8,10b/g;
var str = `12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145`;
var rgx = /b[0-9s]8,10b/g;
var res = str.replace(rgx, `n`)
console.log(res);var str = `12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145`;
var rgx = /b[0-9s]8,10b/g;
var res = str.replace(rgx, `n`)
console.log(res);var str = `12345678 Book
12345678 Book
Book 12345678
Book 12345678
Cabinet 120x30x145`;
var rgx = /b[0-9s]8,10b/g;
var res = str.replace(rgx, `n`)
console.log(res);answered Mar 23 at 11:07
zer00nezer00ne
26.3k32547
26.3k32547
This will remove123 456
– Toto
Mar 23 at 11:31
add a comment |
This will remove123 456
– Toto
Mar 23 at 11:31
This will remove
123 456– Toto
Mar 23 at 11:31
This will remove
123 456– Toto
Mar 23 at 11:31
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%2f55312915%2fremove-numbers-that-contains-8-10-digits-at-different-places-in-a-line%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
2
What regex flavor are you using (i.e. which tool) and how do you apply it? Just getting a regex to match does not remove text, so please make a Minimal, Complete, and Verifiable example to demonstrate.
– Yunnosch
Mar 23 at 10:56
1
Why not replace
bd8,10bwith nothing?– Toto
Mar 23 at 11:00