RESearch questions

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

RESearch questions

Post by pepak » Tue 06 Apr, 2010 07:31

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: 8116
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 67 times
Been thanked: 104 times

Re: RESearch questions

Post by HaRT » Tue 06 Apr, 2010 10:21

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: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: RESearch questions

Post by pepak » Tue 06 Apr, 2010 11:14

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: 1162
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 3 times
Contact:

Re: RESearch questions

Post by Cavaler » Thu 15 Apr, 2010 17:40

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: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: RESearch questions

Post by pepak » Thu 15 Apr, 2010 17:45

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: 1162
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 3 times
Contact:

Re: RESearch questions

Post by Cavaler » Thu 15 Apr, 2010 17:50

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: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: RESearch questions

Post by pepak » Thu 15 Apr, 2010 17:54

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: 1162
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 3 times
Contact:

Re: RESearch questions

Post by Cavaler » Mon 19 Apr, 2010 17:25

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: 1162
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 3 times
Contact:

Re: RESearch questions

Post by Cavaler » Mon 19 Apr, 2010 17:28

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: 1162
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 3 times
Contact:

Re: RESearch questions

Post by Cavaler » Mon 19 Apr, 2010 17:30

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: 1162
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 3 times
Contact:

Re: RESearch questions

Post by Cavaler » Mon 19 Apr, 2010 17:36

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: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: RESearch questions

Post by pepak » Mon 19 Apr, 2010 17:36

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: 1162
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 3 times
Contact:

Re: RESearch questions

Post by Cavaler » Tue 20 Apr, 2010 11:32

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: 1162
Joined: Mon 27 Jun, 2005 12:06
Been thanked: 3 times
Contact:

Re: RESearch questions

Post by Cavaler » Wed 21 Apr, 2010 14:44

OK, here's a new version, with most of the above fixed: http://www.kostrom.spb.ru/FILES/RESearch710.rar

pepak
Posts: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: RESearch questions

Post by pepak » Wed 21 Apr, 2010 14:54

Great! Thanks!

szir
Posts: 8
Joined: Mon 19 Apr, 2010 19:01

Re: RESearch questions

Post by szir » Wed 21 Apr, 2010 17:01

Thanks. Just a small note:
In RESearchEng.hlf, RESearchRus.hlf help files the version is still 6.20

Code: Select all

@Contents
$ #Regular Expression Search and Replace, version 6.20#

Post Reply

Return to “General Plug-In Discussions”