Split string with quotes to new line
-
Hi there.
I have a line in a text-file that containes 1 line with 100’s of keywords between quotes. Each keyword(s) between quotes need to be split to a new line.
Textfile:
"This" "is" "a list" "or" "a string of" "words" "in one" "line" "that" "I" "want to" "split." "Everything" "between the" "quotes" "should be" "on a new" "line" "including the quotes"
Output should become:
"This" "is" "a list" "or" "a string of" "words" "in one" "line" etc...
I have tried some RegEx, but I’m a fullblown noob. It is probably cause my way of thinking and not to mention that I don’t understand/how to read 99% of the “commands”. (current state of short-term-memory also not helping at all)
How would you tackle this? If you have a solution in RegEx can you please type your way of thinking to solve this? I might be asking for much, but I really want to understand.
Thanks for the help in advance. -
Hello, @jajinderk and All,
Very easy to achieve !
-
Open your file in Notepad++
-
Select your long line of words with double-quote delimiters
-
Open the Replace dialog (
Ctrl + H
) -
As the
Find what :
zone is selected with previous contents, replace it with the" "
string ( or the"\x20"
string ) -
Fill in the
Replace with :
zone with"\r\n"
( or"\n"
if you deal with UNIX files )
Note that you must insert the
"
chars in theFind what :
andReplace with :
fields-
Untick all the box options, on the left side of the dialog
-
Select the
Regular expression
search mode -
Click once only on the
Replace All
option ( Do not use theReplace
button )
So, from your INPUT text :
"This" "is" "a list" "or" "a string of" "words" "in one" "line" "that" "I" "want to" "split." "Everything" "between the" "quotes" "should be" "on a new" "line" "including the quotes"
You should get, immediately, this OUTPUT text :
"This" "is" "a list" "or" "a string of" "words" "in one" "line" "that" "I" "want to" "split." "Everything" "between the" "quotes" "should be" "on a new" "line"
Best Regards,
guy038
-
-
OMG! I’m overcomplicating thigs too much. Thank you soo much. I’ve been trying things for litterly hours and the solution was so simple…
1000-thanks.
-
@JajinderK There is one more item to add to what @guy038 wrote which is to make sure that “In selection” is enabled. “In selection” causes the search/replace to only happen within the selected area when you use the “Replace All” button.
If the selection is more than 1024 characters then “In selection” gets turned on automatically. The example you had posted with
"This" "is" "a list" ... "including the quotes"
the selection is 182 characters long meaning that “In selection” does not get turned on automatically and “Replace All” will do the the replacement on the entire file from that point on down or the entire file if “wrap around” is enabled.The odds are you likely were okay as it’s rare to see a quoted single space such as
" "
in a document. -
Hi, @jajinderk, @mkupper and All,
@mkupper, it happened that, when I did the tests of my regex S/R, the
In selection
option was already ticked for some reason !But you’re right about it ! After additional tests, I suppose that the road map shiould be :
-
Open your file in Notepad++
-
Select your long line of words with double-quote delimiters
-
Open the Replace dialog (
Ctrl + H
) -
As the
Find what :
zone is selected with previous contents, replace it with the" "
string ( or the"\x20"
string ) -
Fill in the
Replace with :
zone with"\r\n"
( or"\n"
if you deal with UNIX files )
Note that you must insert the
"
chars in theFind what :
andReplace with :
fields-
Tick, if necessary, the
In selection
option, on the right side of the dialog -
Untick all the box options, on the left side of the dialog
-
Select the
Regular expression
search mode -
Click once only on the
Replace All
option ( Do not use theReplace
button )
Luckily, as you said, a single
space
char, between twodouble-quotes
, does occur very rarely !BR
guy038
-
-
-