• Login
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 799 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.
  • K
    KiWiKo
    last edited by Aug 23, 2023, 3:55 PM

    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

    M 1 Reply Last reply Aug 23, 2023, 4:10 PM Reply Quote 0
    • M
      mkupper @KiWiKo
      last edited by Aug 23, 2023, 4:10 PM

      @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.

      K 2 Replies Last reply Aug 23, 2023, 4:14 PM Reply Quote 2
      • K
        KiWiKo @mkupper
        last edited by Aug 23, 2023, 4:14 PM

        @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
        • K
          KiWiKo @mkupper
          last edited by KiWiKo Aug 23, 2023, 4:27 PM Aug 23, 2023, 4:25 PM

          @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

          M 1 Reply Last reply Aug 24, 2023, 3:47 PM Reply Quote 0
          • M
            mkupper @KiWiKo
            last edited by Aug 24, 2023, 3:47 PM

            @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
            • H
              Horald wilsom
              last edited by Sep 26, 2023, 2:40 PM

              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