RESearch questions

Here you can discuss about your favorite plug-in.
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

RESearch questions

Post by pepak »

I still use the 6.xx branch of RESearch, but I have confirmed these questions are valid for the latest (7.04) release as well. I couldn't find the answer in the documentation, which may be my fault - or maybe they are not there:

1) When searching and/or replacing from editor, empty lines are not matched with regular expression ^$ in a single-line mode. I have to use a multi-line regexp and search for \n\n instead. Why?

2) RESearch supports named subpatterns: (?P<name>pattern) in searches. Can I use them in replace strings, and if so, what is the proper syntax?

3) Is it possible to set the starting value of $R?

4) When replacing from panels, $R is set once at the beginning of the process. Is it possible to force a reset for each file?

5) Is it possible to redefine character classes? For example, I need a slightly reduced \w which would not include numbers. At the moment the only solution I know of requires me to type all characters by hand, e.g. [a-záčď...ž]

6) If some text is selected when I start RESearch from the editor, option "In selection only" is checked. Is it possible to force this option to unchecked by default, regardless of the existence or nonexistence of a selected block?

7) This is more of a feature request: The ability to count the number of found strings (with either search or search/replace) would be nice.

8) I suppose this is a natural consequence of how RESearch reads text from the editor, but maybe it is possible to fix it? The plugin treats the last line rather strangely in respect to a newline character. For example, input

Code: Select all

a
b
c
d
e
(Five lines, each [including the last] ending with a newline character) is, for the purpose of searching, considered to end with e\n\n while in reality it ends with e\n. on the other hand, input

Code: Select all

a
b
c
d
e
(same as above, except that the last line does NOT end with a newline) will only match e but not e\n. But if I replace newlines with hashes (search = \n, replace = #, multiline), I don't get the expected result of a#b#c#d#e but a#b#c#d#e\n (a newline character is added).
User avatar
HaRT
Moderator
Posts: 10806
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 220 times
Been thanked: 357 times

Re: RESearch questions

Post by HaRT »

pepak wrote:1) When searching and/or replacing from editor, empty lines are not matched with regular expression ^$ in a single-line mode. I have to use a multi-line regexp and search for \n\n instead.
I confirm this for RESearch 7.04 in Far 1.75.
pepak wrote:2) RESearch supports named subpatterns: (?P<name>pattern) in searches. Can I use them in replace strings, and if so, what is the proper syntax?
Please look for “named” in pcrepattern.html within the plugin package.
pepak wrote:5) Is it possible to redefine character classes? For example, I need a slightly reduced \w which would not include numbers. At the moment the only solution I know of requires me to type all characters by hand, e.g. [a-záčď...ž]
You might be able to combine \w with positive/negative lookahead on \D/\d.
pepak wrote:7) This is more of a feature request: The ability to count the number of found strings (with either search or search/replace) would be nice.
I wished such a feature recently but I'm not sure if it got to Cavaler's mind.
pepak wrote:8) [...] The plugin treats the last line rather strangely in respect to a newline character.
I confirm this for RESearch 7.04 in Far 1.75.
Фар есть инструмент, а не нянька. © 2009 DrKnS
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Re: RESearch questions

Post by pepak »

HaRT wrote:
pepak wrote:2) RESearch supports named subpatterns: (?P<name>pattern) in searches. Can I use them in replace strings, and if so, what is the proper syntax?
Please look for “named” in pcrepattern.html within the plugin package.
That only deals with searching, not replacing.
User avatar
Cavaler
Posts: 1184
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 10 times
Contact:

Re: RESearch questions

Post by Cavaler »

pepak wrote:1) When searching and/or replacing from editor, empty lines are not matched with regular expression ^$ in a single-line mode. I have to use a multi-line regexp and search for \n\n instead. Why?
Because it's a bug, will be fixed in next release.
pepak wrote:2) RESearch supports named subpatterns: (?P<name>pattern) in searches. Can I use them in replace strings, and if so, what is the proper syntax?
No, it is not implemented yet - but will be at some point.
pepak wrote:3) Is it possible to set the starting value of $R?
No, but you can use ${R+10}
pepak wrote:4) When replacing from panels, $R is set once at the beginning of the process. Is it possible to force a reset for each file?
Well yes, I guess it will be more proper behavior, so it'll be changed in next release.
pepak wrote:5) Is it possible to redefine character classes? For example, I need a slightly reduced \w which would not include numbers. At the moment the only solution I know of requires me to type all characters by hand, e.g. [a-záčď...ž]
No, that's not possible. But you can search for \pL, it will surely work in Unicode version, but maybe in ANSI too.
pepak wrote:6) If some text is selected when I start RESearch from the editor, option "In selection only" is checked. Is it possible to force this option to unchecked by default, regardless of the existence or nonexistence of a selected block?
No, and I don't think I will make it so. Almost every editor I've seen behaves in the same way.
pepak wrote:7) This is more of a feature request: The ability to count the number of found strings (with either search or search/replace) would be nice.
Use Grep instead of Search, and select "Output file names and match count". As to replace, well, I'll think what can be done.
pepak wrote:8) The plugin treats the last line rather strangely in respect to a newline character.
I'll look into it. Stay connected )
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Re: RESearch questions

Post by pepak »

Thanks for the answers.
Cavaler wrote:
pepak wrote:3) Is it possible to set the starting value of $R?
No, but you can use ${R+10}
That does the same thing. Problem solved. Thanks!
Did I miss it or is it an undocumented feature?
pepak wrote:6) If some text is selected when I start RESearch from the editor, option "In selection only" is checked. Is it possible to force this option to unchecked by default, regardless of the existence or nonexistence of a selected block?
No, and I don't think I will make it so. Almost every editor I've seen behaves in the same way.
Well, I wasn't thinking about changing the behavior for all users, but perhaps something on the level of FAR's TechInfo's - a setting in the registry which doesn't have a UI control.
User avatar
Cavaler
Posts: 1184
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 10 times
Contact:

Re: RESearch questions

Post by Cavaler »

pepak wrote:(Five lines, each [including the last] ending with a newline character) is, for the purpose of searching, considered to end with e\n\n while in reality it ends with e\n.
I don't quite get what you mean by 'considered to end with e\n\n'. There was some bug with that before, but it seems to be fixed now.
pepak wrote:(same as above, except that the last line does NOT end with a newline) will only match e but not e\n. But if I replace newlines with hashes (search = \n, replace = #, multiline), I don't get the expected result of a#b#c#d#e but a#b#c#d#e\n (a newline character is added).
Well, that's a bug, will be fixed.
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Re: RESearch questions

Post by pepak »

Cavaler wrote:
pepak wrote:(Five lines, each [including the last] ending with a newline character) is, for the purpose of searching, considered to end with e\n\n while in reality it ends with e\n.
I don't quite get what you mean by 'considered to end with e\n\n'.
It will match e.g. \n{2,}
User avatar
Cavaler
Posts: 1184
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 10 times
Contact:

Re: RESearch questions

Post by Cavaler »

pepak wrote:4) When replacing from panels, $R is set once at the beginning of the process. Is it possible to force a reset for each file?
Well, shortcuts like $R are, as far as I remember, unavailable from panels at all. That's not good, maybe, but - how did you manage to use them?
User avatar
Cavaler
Posts: 1184
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 10 times
Contact:

Re: RESearch questions

Post by Cavaler »

pepak wrote:
Cavaler wrote:
pepak wrote:(Five lines, each [including the last] ending with a newline character) is, for the purpose of searching, considered to end with e\n\n while in reality it ends with e\n.
I don't quite get what you mean by 'considered to end with e\n\n'.
It will match e.g. \n{2,}
It doesn't, in latest versions.
User avatar
Cavaler
Posts: 1184
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 10 times
Contact:

Re: RESearch questions

Post by Cavaler »

pepak wrote:
Cavaler wrote:
pepak wrote:3) Is it possible to set the starting value of $R?
No, but you can use ${R+10}
That does the same thing. Problem solved. Thanks!
Did I miss it or is it an undocumented feature?
There is a Note for that at the bottom of help page for "Replacement text"
User avatar
Cavaler
Posts: 1184
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 10 times
Contact:

Re: RESearch questions

Post by Cavaler »

pepak wrote:6) If some text is selected when I start RESearch from the editor, option "In selection only" is checked. Is it possible to force this option to unchecked by default, regardless of the existence or nonexistence of a selected block?
Well, there IS already an option for that, appeared in version 6.46
That's what happens with developing a plugin for more than 10 years, I don't remember all the features myself anymore...
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Re: RESearch questions

Post by pepak »

Cavaler wrote:
pepak wrote:4) When replacing from panels, $R is set once at the beginning of the process. Is it possible to force a reset for each file?
Well, shortcuts like $R are, as far as I remember, unavailable from panels at all. That's not good, maybe, but - how did you manage to use them?
Apparently they don't work anymore with 7.04, but they worked for me with the 6.xx branch. I don't remember which particular version.
User avatar
Cavaler
Posts: 1184
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 10 times
Contact:

Re: RESearch questions

Post by Cavaler »

pepak wrote:
Cavaler wrote:
pepak wrote:4) When replacing from panels, $R is set once at the beginning of the process. Is it possible to force a reset for each file?
Well, shortcuts like $R are, as far as I remember, unavailable from panels at all. That's not good, maybe, but - how did you manage to use them?
Apparently they don't work anymore with 7.04, but they worked for me with the 6.xx branch. I don't remember which particular version.
That's really strange. I can't find any trace of it in history, or in sources, and help says - not supported )
However, I'll try to (re-)implement something.
User avatar
Cavaler
Posts: 1184
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 10 times
Contact:

Re: RESearch questions

Post by Cavaler »

OK, here's a new version, with most of the above fixed: http://www.kostrom.spb.ru/FILES/RESearch710.rar
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Re: RESearch questions

Post by pepak »

Great! Thanks!
Post Reply

Return to “General Plug-In Discussions”