split lines according to condition
Moderators: AmigoJack, bbadmin, helios, MudGuard
split lines according to condition
Hi,
I want to split a line after a certain number of ["].
How to i do this?
Thanks in advance!
//A.
I want to split a line after a certain number of ["].
How to i do this?
Thanks in advance!
//A.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Do you want to insert a newline into each line after its nth double quote symbol, for some n?
If so, and if, say, n = 6, try:
Use "Posix" regular expression syntax:
If so, and if, say, n = 6, try:
Use "Posix" regular expression syntax:
Search | Replace... (<F8>):Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
Find what: ^([^"]*"){6}
Replace with: \0\n
[X] Regular expression
Replace All
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Sorry about that. The problem was, since i had rows where there were not suppose to be an [enter] i thought that maybe if i remove all the [enters] including the onces at the end of every row where they're suppose to be and then separate that long one line every number of symbols that i desired.
Problem with that was that the line were over 33 milj characters long. not popular.
so this is how it looks;
ROW 1 "field1";"field2";"field3";"field4" [enter] <--- ok enter
ROW 2 "field1";"field2";"field3";"[enter] <---not ok enter
"field3";"field4"; [enter] <--- ok enter
ROW 3 [....]
is this understandable?
//A.
Problem with that was that the line were over 33 milj characters long. not popular.
so this is how it looks;
ROW 1 "field1";"field2";"field3";"field4" [enter] <--- ok enter
ROW 2 "field1";"field2";"field3";"[enter] <---not ok enter
"field3";"field4"; [enter] <--- ok enter
ROW 3 [....]
is this understandable?
//A.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
You really are not being clear. Do you mean that you want a newline after every (say) twelfth double quote symbol, regardless of where the newlines are initially?
If so you might do this in two steps:
1. Insert a newline after every second double quote symbol if there isn't already one there:
If so you might do this in two steps:
1. Insert a newline after every second double quote symbol if there isn't already one there:
2. Remove every sixth newline:Find what: (([^"]*"){2})(.)
Replace with: \1\n\3
[X] Regular expression
Replace All
These assume you are using "Posix" regular expression syntax:Find what: (.+)\n(.+)\n(.+)\n(.+)\n(.+)\n(.+)
Replace with: \1\2\3\4\5\6
[X] Regular expression
Replace All
If this is not what you want, you will have to explain your requirements more clearly.Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
Ok. I'll try to explain it in another way, thanks for being patient by the way.
I have a set of data that contains say 20 fields (columns) on every row. Every row is separated with an "enter"
But, some of the rows are splitted after only the 10th field having the other 10 fields (on that supposed row), continuing on the next row. So that row has to "enters" instead of one.
Now, what i want to do is remove the "split" so that the row of the 20 fields are intact again. hence, remove the enter after the 10th field.
fields, like i said before are quoted with " and separated with ;
I have a set of data that contains say 20 fields (columns) on every row. Every row is separated with an "enter"
But, some of the rows are splitted after only the 10th field having the other 10 fields (on that supposed row), continuing on the next row. So that row has to "enters" instead of one.
Now, what i want to do is remove the "split" so that the row of the 20 fields are intact again. hence, remove the enter after the 10th field.
fields, like i said before are quoted with " and separated with ;
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm