Search does not work with "in selection"

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 282
Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland

Search does not work with "in selection"

Post by sexy96 »

Szukaj, nie wczytuje zaznaczonego textu przy aktywnym "w zaznaczeniu"

Image

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

sexy96
Selecting text + "In selection" = limits the scope of the search.
What you would expect to see in the search string, if it is selected, for example, a few paragraphs?

Offline
Posts: 282
Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland

Post by sexy96 »

marked "from the beginning"

Image

"test" is loaded into the window.

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

sexy96
Clearly. In this case you do a search in the entire (whole) text. And there is not a zero probability of finding the highlighted word again and again. But narrowing the search down to "In selection", trying to look for the selected text becomes meaningless, since you "already found" it.

Offline
Posts: 282
Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland

Post by sexy96 »

I want to convert: (Chcę zamienić)
ascii->ascii
Windows->WINDOWS

I replaced it (tu zamieniłem) ascii->ascii

Image

now i want to swap (teraz chcę zamienić) Windows->WINDOWS

1.but to load "WINDOWS" to "what?", I need to change direction in the table
"In the selection" for another example on "From the beginning" and just click on the icon "Replace ..."
and again mark the direction "In selection."

(1.aby wczytać "WINDOWS" do "Co:", muszę w tabeli kierunek zmienić
"W zaznaczeniu" na inne np. na "Od początku" i dopiero kliknąć na ikonę "Zamień..."
i ponownie zaznaczyć kierunek "W zaznaczeniu.")

Image

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

sexy96 wrote:I want to convert: (Chcę zamienić)
ascii->ascii
Windows->WINDOWS
1. ascii->ASCII ???
You want convert some words in uppercase?

In SearchReplace.js you can to do that in one pass

What: (ascii|Windows)
With: return $1.toUpperCase()
Options:
[*] Regular expressions
[*] Replace with function
Button: Replace all

Image
notes:
a. List all the words in parentheses, separating them with "|" (pipe, vertical bar)
b. The option "Multiline" (on the screenshot) in fact do not need.


2.
sexy96 wrote:1.but to load "WINDOWS" to "what?", I need to change direction in the table
You can type, not load.

Offline
Posts: 282
Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland

Post by sexy96 »

And when will I want to change the order?
(A gdy będę chciał zmienić kolejność?)
3->1(4x) and 4->2(4x)

It's easier to "mark the ascii" and click on the icon
"Replace ..." in the Toolbar, instead of writing it below
(Nie łatwiej "zaznaczyć ascii" i klinąć na ikonę
"Zamień..." w Toolbar, zamiast wypisywać to poniżej)

What: (ascii|Windows)
With: return $1.toUpperCase()

Image
I do not have:
Replace with function
and
Multiline

I have x86, because I am using: Aspell
(Mam x86, ponieważ używam: Aspell)

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

begin with the end (zacznę od końca)
1.
sexy96 wrote:I have x86...
I'm too. So what?

2.
sexy96 wrote:I do not have:
Replace with function...
Pay attention to detail! I use in the example standard script "SearchReplace.js" (with Scripts Plugin). See text and screenshot. This script is more powerful than the standard comand "Replace".

3.
sexy96 wrote:3->1(4x) and 4->2(4x)

If you want to do that: "button31=..." -->> "button29=..."
In "SearchReplace.js" you can use some arithmetic (31-2=29, 3-2=1, 4-2=2)

What: (\d+)(=)
With: return $1-2+$2
Options:
[*] Regular expressions
[*] Replace with function
Button: Replace all

notes:
1) In "With:" we take the first reference back and subtract from it two - [$1-2...]. Then "glue" the second reference back - [...+$2].
2) If you have only short (single digits) numbers [0-9], you can use (\d)(=) instead (\d+)(=)
3) We need second group (=) to identify strings like "\SysWOW64\" in text and ignore them.

4.
sexy96 wrote:It's easier to "mark the ascii" and click on the icon...
I do not persuade, but only to inform about the other options.

Offline
Posts: 282
Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland

Post by sexy96 »

Thanks, interesting proposition.

1.
It works great:
What: (\d+)(=)
With: return $1-2+$2

Image

but it does not work
What: (\d+)(=)
With: return $1+2+$2

2.
"Delete empty lines";
"Delete leading and trailing spaces";
"Zap symbols with spaces";

How to change it to polish?

change here, causes the subtitles to disappear completely
if (nStringID == STRID_TEMPLATE1)
return "Delete empty lines";
if (nStringID == STRID_TEMPLATE2)
return "Delete leading and trailing spaces";
if (nStringID == STRID_TEMPLATE3)
return "Zap symbols with spaces";

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

1.
sexy96 wrote:but it does not work
What: (\d+)(=)
With: return $1+2+$2
1) "return" is missing on your screenshot
2) JScript operator "-" has only one meaning: operation of subtraction.
But JScript operator "+" has two functions: the operation of addition and string concatenation.
JScript does not know what is our reference back ($1) and uses the "+" sign to mean "concatenation".
To avoid this, we will have to explain JScript that $1 is a number and that we need to do addition:

What: (\d+)(=)
With: return parseInt($1)+2+$2

...and "yes", [ return parseInt($1)-2+$2 ] would work too, but I was too lazy to make a universal solution.

2.
sexy96 wrote:How to change it to polish?
Two ways:
1) Hard and dangerous: You can modify "SearchReplace.ini" (not "SearchReplace.js" !!!)
2) A simple and safe: After any template selection in the same menu will appear additional item "rename...". Select it and replace the text you need.
Repeat this procedure for each of the three templates.

Offline
Posts: 282
Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland

Post by sexy96 »

Thanks, it's universal
parseInt($1)+2+$2
parseInt($1)-2+$2
parseInt($1)*2+$2
works without "return"

I changed into ini polish, thanks.

1."Zamień..." Call("Scripts::Main", 1, "SearchReplace.js") Icon(13)
2."Zamień..." Call("Scripts::Main", 1, "SearchReplace.js", `-DefButtonID=1019 /*IDC_REPLACEALL_BUTTON*/`) Icon(13)

What is the difference between 1 and 2?
They look and act the same.

and what does "Zap" mean?
return "Zap symbols with spaces";

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

1.
sexy96 wrote:I changed into ini polish, thanks.
Only the hard way? :D

2.
sexy96 wrote:What is the difference between 1 and 2?
They look and act the same.
Not the same. ("1") is equivalent to
Call("Scripts::Main", 1, "SearchReplace.js", `-DefButtonID=1016 /*IDC_FIND_BUTTON*/`) Icon(13)
in other words:
(1) press {ENTER} = press button "Find next"
(2) press {ENTER} = press button "Replace all"
But if you press buttons with the mouse only (not keyboard), then, indeed, there is no difference (for you).

3.
sexy96 wrote:and what does "Zap" mean?
"Zap" is slang ~ shoot, kill, to erase.
In russian version used verb "заменить" ("replace").
You can see the RegExp in that template. In "What:" we have [^\n] (A negative character set. Matches any character exept "any newline"). In "With:" we have one space character.

Offline
Posts: 282
Joined: Thu Sep 10, 2015 9:53 am
Location: Deutschland

Post by sexy96 »

1.It works very well
2.I usually use a mouse and an icon.
3. "Zap", I do not see the practical application.

Offline
Posts: 2
Joined: Mon Mar 04, 2024 4:26 am

Re: Search does not work with "in selection"

Post by chitra150 »

What is mean by- Szukaj, nie wczytuje zaznaczonego textu przy aktywnym "w zaznaczeniu"?
Post Reply