Community
    • Login

    how to find commas between numbers, exclude them, and only find the rest of them

    Scheduled Pinned Locked Moved General Discussion
    6 Posts 3 Posters 742 Views
    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.
    • KiWiKoK
      KiWiKo
      last edited by

      I don’t know if that makes sense but for example:

      00:00:00,866 --> 00:00:01,584

      I want to find commas, dots, exclamation points, questions marks, and stuff in my text which i was able to do with this: [,.!?]
      But then I ran into a problem where it catches the commas between numbers like in the above example which i don’t want so what expression should i use now

      I made a reddit post but didnt get a reply yet sadly
      https://www.reddit.com/r/notepadplusplus/comments/15un7xx/very_new_to_notepad_i_just_need_quick_help/

      Thanks in advance

      mkupperM 1 Reply Last reply Reply Quote 0
      • mkupperM
        mkupper @KiWiKo
        last edited by

        @KiWiKo Rather then thinking about what you can exclude try thinking about what you can include. It’s easier to think about what you are aiming for rather than what you are trying to miss.

        The subject line in the reddit post provided me with an “aim for” clue. “Very new to notepad++ i just need quick help (removing punctuation from text)”

        You want to remove punctuation that is adjacent to letters. This will find instances of a letter followed by the punctuation you have identified. ([A-Za-z])[,.!?] and replace with \1. Fortunately, in English, and I suspect most languages, we don’t have [,.!?] followed by [A-Za-z] and so I did not try to search/replace that version.

        KiWiKoK 2 Replies Last reply Reply Quote 2
        • KiWiKoK
          KiWiKo @mkupper
          last edited by

          @mkupper oh my goood my lord and savior that \1 was exactly what i was looking for cause i figured out how to find commas and stuff next to letter but i didnt want to remove the letter as well oops
          thank you!

          1 Reply Last reply Reply Quote 0
          • KiWiKoK
            KiWiKo @mkupper
            last edited by KiWiKo

            @mkupper oh oh and also, how can i include punctuation at the end of sentences like here too:

            00:00:15,383 --> 00:00:16,316
            that’s 500.

            28

            mkupperM 1 Reply Last reply Reply Quote 0
            • mkupperM
              mkupper @KiWiKo
              last edited by

              @KiWiKo said in how to find commas between numbers, exclude them, and only find the rest of them:

              @mkupper oh oh and also, how can i include punctuation at the end of sentences like here too:

              that’s 500.

              Search for ([0-9])[,.!?](\x20|$)
              Replace with \1\2

              The first group ([0-9]) matches and saves in \1 a decimal digit. The [,.!?] matches the set of punctuation characters you identified earlier. The second group (\x20|$) matches either a space or the end of the line. I used \x20 instead of a space for readability. You can use ( |$) but it’s not always obvious there is a space in there.

              If you also want to remove punctuation at the end of sentences that end with a letter then use ([A-Za-z0-9])

              1 Reply Last reply Reply Quote 1
              • Horald wilsomH
                Horald wilsom
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote -2
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors