I have a bunch of text files and I want to only replace the first instance of the \n with something else.
But, no matter what I do it replaces every \n!
Help.
Replace only the first \n
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Can't test on Wild Edit now, but does this work?
Find: ^(.*[^\n])\n(.*)
Replace with: \1~XXX~\2
Would replace the first "\n" with "~XXX~"
I know this DOES NOT work in TextPad, because it cannot scan multiple lines, but perhaps WildEdit can handle it....
Find: ^(.*[^\n])\n(.*)
Replace with: \1~XXX~\2
Would replace the first "\n" with "~XXX~"
I know this DOES NOT work in TextPad, because it cannot scan multiple lines, but perhaps WildEdit can handle it....
Hope this was helpful.............good luck,
Bob
Bob
didn't work
No, it replaced every thing with ~XXX~
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
\A should match the beginning of the file, but it doesn't seem to work: it matches the beginning of every line.
If your files aren't too big, you might try
If your files aren't too big, you might try
But this might be rather slow, as the regex matches and captures the whole file.Find what: ^([^\r\n]*)\r?\n(.*)
Replace with: $1 something else $2
[X] Regular expression
[X] Replacement format
Options
[ ] '.' does not match a newline character [i.e., not selected]