how to find commas between numbers, exclude them, and only find the rest of them
-
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 nowI 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
-
@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. -
@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! -
@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
-
@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])
-
This post is deleted!