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;








0















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









share|improve this question



















  • 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,10b with nothing?

    – Toto
    Mar 23 at 11:00

















0















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









share|improve this question



















  • 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,10b with nothing?

    – Toto
    Mar 23 at 11:00













0












0








0








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









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 replace bd8,10b with nothing?

    – Toto
    Mar 23 at 11:00












  • 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,10b with 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












3 Answers
3






active

oldest

votes


















1














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






share|improve this answer






























    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 use
    g (global) option.



    Note that you can not use s instead of the space, as s matches also
    CR and LF and we don't want this.



    For a working example see https://regex101.com/r/1hsGzT/1






    share|improve this answer
































      0














      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);








      share|improve this answer























      • This will remove 123 456

        – Toto
        Mar 23 at 11:31











      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
      );



      );













      draft saved

      draft discarded


















      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









      1














      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






      share|improve this answer



























        1














        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






        share|improve this answer

























          1












          1








          1







          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






          share|improve this answer













          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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 11:03









          Yassin HajajYassin Hajaj

          14.8k73062




          14.8k73062























              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 use
              g (global) option.



              Note that you can not use s instead of the space, as s matches also
              CR and LF and we don't want this.



              For a working example see https://regex101.com/r/1hsGzT/1






              share|improve this answer





























                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 use
                g (global) option.



                Note that you can not use s instead of the space, as s matches also
                CR and LF and we don't want this.



                For a working example see https://regex101.com/r/1hsGzT/1






                share|improve this answer



























                  1












                  1








                  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 use
                  g (global) option.



                  Note that you can not use s instead of the space, as s matches also
                  CR and LF and we don't want this.



                  For a working example see https://regex101.com/r/1hsGzT/1






                  share|improve this answer















                  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 use
                  g (global) option.



                  Note that you can not use s instead of the space, as s matches also
                  CR and LF and we don't want this.



                  For a working example see https://regex101.com/r/1hsGzT/1







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  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





















                      0














                      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);








                      share|improve this answer























                      • This will remove 123 456

                        – Toto
                        Mar 23 at 11:31















                      0














                      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);








                      share|improve this answer























                      • This will remove 123 456

                        – Toto
                        Mar 23 at 11:31













                      0












                      0








                      0







                      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);








                      share|improve this answer













                      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);






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 23 at 11:07









                      zer00nezer00ne

                      26.3k32547




                      26.3k32547












                      • This will remove 123 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





                      This will remove 123 456

                      – Toto
                      Mar 23 at 11:31

















                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                      155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해