How to find the first space in all lines?
-
I have a txt file with more than 3 thousand lines, I want to detect the first space in all lines and add a ]
Original file format[fgggj oooo m6cmp5
[5jgidd udd64j kkrt7 8d66sdjnd
[hfhfh maoerchgu 996d63542
[mmnkiiuy45 oiudzzc3Would be like this
[fgggj]oooo m6cmp5
[5jgidd]udd64j kkrt7 8d66sdjnd
[hfhfh]maoerchgu 996d63542
[mmnkiiuy45]oiudzzc3Next, use a regex that eliminates everything outside []
Final result
[fgggj]
[5jgidd]
[hfhfh]
[mmnkiiuy45]It’s possible? Thank you for any help.
-
Find what :
^(\S++)[^\r\n]++
Replace with :$1] -
Thank you very much, Coises. It worked perfectly, saved my weekend! I applied the regex, using Linux Debian Sid, Notepad++ running via wine. Sorted out!
-
Sorry to bother you, but I have a question that I may need in the future. If I wanted to do the opposite, in the end result removing everything inside [] including [] itself, would it be possible? The end result would be this:
oooo m6cmp5
udd64j kkrt7 8d66sdjnd
maoerchgu 996d63542
oiudzzc3 -
@Emalino-Emalero said in How to find the first space in all lines?:
Sorry to bother you, but I have a question that I may need in the future. If I wanted to do the opposite, in the end result removing everything inside [] including [] itself, would it be possible? The end result would be this:
Find what :
^(\S++)\h
Replace with : (empty) -
Thanks!
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