How do I use new lines or tabs in regular expressions? For example: I'd like to replace all pipes (|) in a file with new lines, and then all colons (:) with tabs. This would turn this:
First Name: Foo|Last Name: Bar
First Name: Foo
Last Name: Bar
However, if I attempt to replace "|" with "\n" it literally inserts "\n", even with regex on. This is how I used to do the same thing with Textpad. Is this possible?
The search functions are done by the Scintilla component, which is a 3rd party editing component used by Notepad++ and for regexp, it searches one line at a time. It grabs the text of the current line, excluding \r and \n characters so that it is why they are not searchable. For non-regexp searches, it looks like it goes through the text character by character, which includes \r and \n.
I am actually working on modifying Scintilla for myself so that it does search for \r and \n (and also adding a few other things, such as deleting a line that a match is found on. And I also changed it's regexp library to use pcre because I didn't like the limitations of the normal regexp syntax that it used) but I am not really sure I plan on releasing it. I've been using it for a week or so but it's not quite ready anyway.
i hope you do release it, i'd love multiline PCRE
I have to apologize. You guys are cool, and I was a typical luser. Of course I was using version 2.8, and when I upgraded to 2.9 the requested features worked fine. When in doubt, always upgrade first, eh? (And reboot if it's Windows)
Well, it seems like replacing some character by \t or \n works fine, but if i try to find any \n or \t to replace them for another char (like changing all line breaks by commas), i cant do this because N++ just dont find them.
Is there another version that fix this problem ?
You can find and replace "\t" when the regular expression is checked.
However, you can not find and replace "\n".
Unfortunately I don't have the solution for the moment.
Does this mean the regexp search is limited to a single line? Seems so to me..
However, without regexp on, you can make a multi-line selection, press Ctrl-f and it will use the selection as search mask - this works.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.