Community
    • Login

    Deleting all numbers with specific letter(s)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 4 Posters 2.2k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Berniukas NeziniukasB Offline
      Berniukas Neziniukas
      last edited by

      Hello. I have lines like these:
      9.15 Premjera. Senis.395 s.
      10.20 Premjera. Štutgarto kriminalinė policija.8/12 s.
      I want to delete every “395 s.” and “8/12 s.” without disturbing other numbers. Also these numbers keeps changing like (395 s., 396 s., 397 s. and 8/12 s., 8/13 s.
      Is it possible?

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS Offline
        Scott Sumner @Berniukas Neziniukas
        last edited by Scott Sumner

        @Berniukas-Neziniukas

        Why does it seem like every problem is a regex problem today?

        Try this:

        Find what zone: \.(?:(?:[0-9/]+)|(?:\d+))\x20s\.
        Replace with zone: leave this empty
        Wrap around checkbox: as desired
        Search mode: Regular expression
        Action: Press Replace / Replace All button

        Here’s an explanation of how it works:

        • [Match the character “.” literally][1 ] \.
        • [Match the regular expression below][2 ] (?:(?:[0-9/]+)|(?:\d+))
          • [Match this alternative (attempting the next alternative only if this one fails)][3 ] (?:[0-9/]+)
            • [Match the regular expression below][2 ] (?:[0-9/]+)
              • [Match a single character present in the list below][4 ] [0-9/]+
                • [Between one and unlimited times, as many times as possible, giving back as needed (greedy)][5 ] +
                • [A character in the range between “0” and “9”][4 ] 0-9
                • [The literal character “/”][6 ] /
          • [Or match this alternative (the entire group fails if this one fails to match)][3 ] (?:\d+)
            • [Match the regular expression below][2 ] (?:\d+)
              • [Match a single character that is a “digit” (any symbol with a decimal value in the active code page)][7 ] \d+
                • [Between one and unlimited times, as many times as possible, giving back as needed (greedy)][5 ] +
        • [Match the character “ ” which occupies position 0x20 (32 decimal) in the character set][8 ] \x20
        • [Match the character “s” literally (case sensitive)][6 ] s
        • [Match the character “.” literally][1 ] \.

        Created with RegexBuddy

        [1 ]: http://www.regular-expressions.info/characters.html#special
        [2 ]: http://www.regular-expressions.info/brackets.html
        [3 ]: http://www.regular-expressions.info/alternation.html
        [4 ]: http://www.regular-expressions.info/charclass.html
        [5 ]: http://www.regular-expressions.info/repeat.html
        [6 ]: http://www.regular-expressions.info/characters.html
        [7 ]: http://www.regular-expressions.info/shorthand.html
        [8 ]: http://www.regular-expressions.info/nonprint.html

        Berniukas NeziniukasB 1 Reply Last reply Reply Quote 2
        • guy038G Online
          guy038
          last edited by

          Hello, @berniukas-neziniukas, @scott-sumner and All,

          Scott, am I missing something obvious ?!

          As, from the sentence :

          I want to delete every “395 s.” and “8/12 s.” without disturbing other numbers.

          It seems, to my mind, that the correct search regex is, simply, the obvious one, below :

          \.(395|8/12)\x20s\.

          Cheers,

          guy038

          1 Reply Last reply Reply Quote 1
          • Terry RT Offline
            Terry R
            last edited by

            @guy038 it appears you did miss the obvious. That being the next sentence:

            @Berniukas-Neziniukas said:

            Also these numbers keeps changing like (395 s., 396 s., 397 s. and 8/12 s., 8/13 s.

            So the numbers aren’t always the same, hence your regex will miss other “similar” but different numbers.

            Terry

            1 Reply Last reply Reply Quote 4
            • guy038G Online
              guy038
              last edited by guy038

              Hi, @terry-r,

              Ah, I see ! Actually, the OP meant :

              I want to delete every expression “395 s.” and “8/12 s.” and similar ones, without disturbing other numbers, in other forms !

              I didn’t notice the difference :-((

              Best Regards,

              guy038

              Berniukas NeziniukasB 1 Reply Last reply Reply Quote 3
              • Terry RT Offline
                Terry R
                last edited by

                @guy038, yes we seem to often find posters whose primary language is NOT English, doing a fine job of writing in English, but those subtle nuances are what impart a lot more information.

                I’m actually going through the old posts (a little project of mine, we will see if it works out) and invariably the writing styles of the OPer is what causes most of the issues initially. Just getting the understanding right before launching into a regex is key to a good solution.

                Just an observation

                Terry

                1 Reply Last reply Reply Quote 4
                • Berniukas NeziniukasB Offline
                  Berniukas Neziniukas @Scott Sumner
                  last edited by

                  @Scott-Sumner This did the trick. You saved me a lot of time, thank you very much!

                  1 Reply Last reply Reply Quote 1
                  • Berniukas NeziniukasB Offline
                    Berniukas Neziniukas @guy038
                    last edited by

                    @guy038 Sorry for being unclear! Sometimes I read my older posts and wonder how people managed to find any sense in them. That’s why I post so rarely…

                    1 Reply Last reply Reply Quote 1

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors