distal-attribute
distal-attribute
distal-attribute
distal-attribute

replace commas of sql with newlines

michaelgang posted 3 years ago in General
I tried to use the editor ctrl+r with regular expressions to replace commas with new lines.
i tried \n and \\n and it did not work.
how can i do it?
kalvaro posted 3 years ago
I can confirm it's not working as expected. If you use \n in a replacement expression you n as replacement.
ansgar posted 3 years ago
The replacement string is never a regular expression, and things like \n \t and maybe more should be usable with or without having the regular expression option activated. Found this issue report for Lazarus, which probably helps me with some code change for SynEdit.
ansgar posted 3 years ago
Not so easy as that might seem. Thought I just string-replace these \n with a real #13#10 right before replacement is processed. Now, TSynMemo.SearchReplace does this when I replace commas with newlines:
original:

TSynMemo wrote: 1,2,3,4


replaced:

TSynMemo wrote: 1


2,3,4



Looks like a bug in SynEdit.
ansgar posted 3 years ago
Looks like SynEdit always processes only the number of lines which is found in the original text:

TSynEdit wrote: 1,
2,
3,
4,
5,
6,
7


is replaced with:

TSynEdit wrote: 1

2

3

4,
5,
6,
7

ansgar posted 3 years ago
Hm, looks as if even Lazarus still has the above mentioned issue with the number of processed lines. Think we need a different, working approach here. Fixing SynEdit does not seem realistic to me.
ansgar posted 3 years ago
Done in r3928, supporting \n and \t now. Accepting the above bug in SynEdit, which is the same as in other applications, e.g. PSPad. The user has to use backward search to overcome that bug.
michaelgang posted 3 years ago
That's cool :-)
I am just asking myself, if i make replace all with a regular expresssion, that the program should automatically replace everything backwards?
Maybe a suggestion.
ansgar posted 3 years ago
Again, please note that \n and \t are not part of the regular expression feature.

Your suggestion is to automatically check the "backwards" radio button when the replacement string contains \n and "replace all" is clicked. Well, why not.
ansgar posted 3 years ago
Done in r3929

michaelgang posted 3 years ago
Vielen Dank !!!
ansgar posted 3 years ago
Danke dir für die gute Idee - hatte bereits graue Haare wegen des SynEdit Bugs und dann so eine einfache Idee, super.
michaelgang posted 3 years ago
smile

Please login to leave a reply, or register at first.