Find and delete all text after //
-
Hello,
I need to clean a large .txt file. See the example below:
LINE01 //BLABLABLA01
LINE02 //BLABLA
(…)I want to delete all text and numbers after the “//” in a given line so it looks like this:
LINE01
LINE02
(…)Thank you
-
You probably want to eliminate spaces before the
//as well.I’d try this:
- Bring up the Replace window (ctrl+h).
- Find what box:
(?-s)(.*?)\s*//.* - Replace with box:
\1 - Search mode: Regular expression
- Wrap around: ticked
- Press the Replace All button.
Learn more about this kind of searching/replacing here: https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation
-
- Search
- Replace…
- Search Mode: Regular expression
- Find what:
[ ]*//.*$ - Replace with: (empty string)
- Replace All
-
Hi, @andre-silva, @alan-kilborn, @supasillyass and All
Here is a third possible regex, just for fun !
SEARCH
(?-s)\h*//.*REPLACE
Leave EMPTYOf course, we, all, suppose that, assuming the text :
LINE01 //BLAB // LABLA01@andre-silva expect :
LINE01and not :
LINE01 //BLABCheers,
guy038
-
-
@Alan-Kilborn
Try it 😉 -
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