Hi all,
I'm really new to Geany and I'm trying to figure out how use the regex search and replace with and end of line marker.
For instance, in perl/python regex syntax, I'd like to replace "\s+$" (all whitespace at the end of each line) with "", where '$' is the end of line marker. The regex in Geany doesn't seem to under stand '$' and I can't figure out how else to do.
Clues anyone?
Erik
\s+$ seems to work for me, modulo some marking of white space in the next line on some occasions. is that what you mean by "doesnt seem to understand"? or is something else the problem? did you check the checkbox "use regular expressions"?
best, paul
On 07/29/2010 02:43 PM, Erik de Castro Lopo wrote:
Hi all,
I'm really new to Geany and I'm trying to figure out how use the regex search and replace with and end of line marker.
For instance, in perl/python regex syntax, I'd like to replace "\s+$" (all whitespace at the end of each line) with "", where '$' is the end of line marker. The regex in Geany doesn't seem to under stand '$' and I can't figure out how else to do.
Clues anyone?
Erik
daspostloch wrote:
\s+$ seems to work for me, modulo some marking of white space in the next line on some occasions. is that what you mean by "doesnt seem to understand"?
Yes. I'm a refugee from the Nedit text editor. With the regex above with Nedit the search and replace of this (underscores as whitespace):
aaa___ ____ bbbb______
would result in:
aaa
bbbb
With Geany, it removes the empty line giving me this:
aaa bbbb
which is not really what I was after.
Erik
From
http://www.regular-expressions.info/charclass.html :
\s stands for "whitespace character". Again, which characters this actually includes, depends on the regex flavor. In all flavors discussed in this tutorial, it includes [ \t\r\n]. That is: \s will match a space, a tab or a line break. Some flavors include additional, rarely used non-printable characters such as vertical tab and form feed.
So it will eat the spaces and the next \n, etc as well. Hence try " +$" , which works for me.
Best, Paul
On 07/30/2010 12:47 AM, Erik de Castro Lopo wrote:
daspostloch wrote:
\s+$ seems to work for me, modulo some marking of white space in the next line on some occasions. is that what you mean by "doesnt seem to understand"?
Yes. I'm a refugee from the Nedit text editor. With the regex above with Nedit the search and replace of this (underscores as whitespace):
aaa___
bbbb______
would result in:
aaa bbbb
With Geany, it removes the empty line giving me this:
aaa bbbb
which is not really what I was after.
Erik
daspostloch wrote:
I have been writing regexes for a long time :-).
\s stands for "whitespace character". Again, which characters this actually includes, depends on the regex flavor. In all flavors discussed in this tutorial, it includes [ \t\r\n].
I just tried it out with Perl and Python (two langauges I rarely use) and found their behaviour to be the same as that of Geany.
My main use of regexes was actually in the Nedit editor and I had somehow come to assume that Nedit regexes were the standard when obviously this isn't the case.
So it will eat the spaces and the next \n, etc as well. Hence try " +$" , which works for me.
Yes, that does work as long as the trailing whitespace is only spaces. It doesn't work if its a mixture of tabs and spaces. For that something like "[ \t]+$" is required which is a little less convienient than what I was used to, but I'm sure I can learn to live with it.
Cheers, Erik