How I can in texteditor (notepad++) ... need help!

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: How I can in texteditor (notepad++) ... need help!

Post by bob »

Adam Hair wrote:
Frank Quisinsky wrote:Hi there,

or Textpad do this one ...

I have interest on work with "search and replace".
In my opening book lines with priority d to a after 6 moves.

Text format from Shredder's own opening book:

Example:
7- F8E8 a B2B3 a C8G4 a H2H3 a G4F3 a D1F3 a B8D7 a F3E2 a D8A5 a A2A3 a A5A6 a ;
9- G4H5 a G3G4 a H5G6 d F3H4 a D6B4 a E4D5 a C6D5 a ;

I can search with:
9.*d ... and find all what I want to find in a very big file.
Not my problem ...

Means can find the lines after 9 moves (for that example) I have a "d" and not the right "a". In the past lines ended with "d". After x updates and extensions (working daily on my book since three years) I have today this problem!

Now I will replace in these lines d only with ... a

I am not sure what I have to give for an order in Notepad++
"replace with"

Image

Maybe a person can help here?!

Best, sorry for that question and thanks!
Try out this in the night more hours and for the moment I gave up.
To overwork 13.000x "d" is to many work. I think in the file of my book I have around 10.000x d and this is wrong (more blemish).

Best
Frank
Hi Frank,

I am out of practice and I do not have a computer to experiment with, but may be this will work for you:

Find: (9.*)d
Replace: \1a

The parentheses groups together the characters corresponding to 9.*. \1 references the first group in the regular expression, allowing it in this case to remain unchanged.

Hope this works for you.
In my unix world that won't work. 9.*d could match a d in move 10, since 9.* is a regular expression which will match ANYTHING. So if it finds a 9, followed ANYWHERE on the line by a d, that would match and probably not do what you intended. Of course, in unix, that "." is also problematic unless you quote it (\.) since . matches any single character in regular-expression parlance...

Not sure about windows, but "*" is generally NOT what you want when doing search and replace.
Frank Quisinsky
Posts: 6808
Joined: Wed Nov 18, 2009 7:16 pm
Location: Gutweiler, Germany
Full name: Frank Quisinsky

Re: Ready, 2450 I have to check by hand only, THANKS!

Post by Frank Quisinsky »

Hi there,

more as 30.000 x d (with "d ;") on the end of the line ... easy to changed that in "a ;"

After this one 13.099 x "d"
The problem I had ...

With the parameter from Adam now only 2.450 x "d" in my book.

Examples:
4 G1F3 a C8G4 a H2H3 b G4H5 c G3G4 a H5G6 a F3E5 a B8D7 a E5G6 a H7G6 a E2E4 a E7E6 a C1F4 a D5E4 d D3E4 a D8B6 a D1C1 a B6A6 a ;
4- G7G6 b E1G1 a F8G7 a B1D2 a E8G8 a E2E4 a C8G4 a H2H3 a G4F3 a D1F3 a E7E5 a D2B3 a B8D7 d A2A4 a D5D4 a A4A5 a C6C5 a ;
4- C8F5 b F3H4 c F5G4 a H2H3 a G4H5 a G3G4 a H5G6 a C2C3 a E7E5 a E1G1 a B8D7 a B1D2 a D7C5 d C3C4 a F8D6 a G4G5 a F6H5 a ;
4- B8D7 b E1G1 a E7E5 a E2E4 a D5E4 a D3E4 a F8C5 a D1E2 a E8G8 a B1D2 a D8C7 a A2A4 a A7A5 d D2B3 a C5E7 a F3H4 a G7G6 a ;

Here I have to checked and changed the last 2450 x d by hand. Because possible that "d" is lowest priority. So I can by hand only to find out ... if "d" is included after 6 moves I can changed to "a". And all is clean! I set the priority "d" only for the first 5 moves by hand. Most of the priorities I set in the last three years by hand and all the time I had the "d" problem. Again now it's solved. If I am ready only "d" in my book if "d" = lowest priority.

Moves after the "d" Comes from engines ... engines find out during the test-run. So most of my book comes from the 280.000 engines games from my database. And this 280.000 games are checked game by game per hand and are good.

http://www.amateurschach.de/download/_f ... 7a.dat.zip
if you like for looking ... my opening book in Shredder's *.dat "textformat".

e = short draw lines (games undo move 20 ... lines deactivated with "e". Around 600x

f = bad opening lines (deactivated if engines give 1-3 moves after opening book bad evals) ... around 8.000x.

Again ...
Many thanks because to check now 2450 lines with "d" only ... one or two days work, not more.

Best
Frank
Milos
Posts: 4190
Joined: Wed Nov 25, 2009 1:47 am

Re: How I can in texteditor (notepad++) ... need help!

Post by Milos »

Frank Notepad++ is a very powerful editor (Linux fanboys would not agree but it is no worse than any emacs or vi editor) and using regular expressions really provides a lot of power.
My advice try learning them.
Here is an excellent tutorial.
Frank Quisinsky
Posts: 6808
Joined: Wed Nov 18, 2009 7:16 pm
Location: Gutweiler, Germany
Full name: Frank Quisinsky

Re: How I can in texteditor (notepad++) ... need help!

Post by Frank Quisinsky »

Hi Milos,

yes, good tipp.
Many things I know but it make sense to learn more.

So I will study the file.

Best
Frank

PS:
Often I am thinking I am to old for all this.
But more and more I have interest to create my own chess program. With all my knowledge to computer chess ... 1.000 Elo should be possible ...

:-)

No, no ... I am more the helper.
Wasp is the big topic for me. I will help John a bit in testing and if I have a clear PGN from the lines from my book I create a really good book John will be a like a lot.

I like Notepad a lot ... working since around 10 years with Notepad ... but more easy things. Before I am using Textpad ... also good but Notepad I think is clearly better and more easy to handle with more and interesting features.
Milos
Posts: 4190
Joined: Wed Nov 25, 2009 1:47 am

Re: How I can in texteditor (notepad++) ... need help!

Post by Milos »

bob wrote:In my unix world that won't work. 9.*d could match a d in move 10, since 9.* is a regular expression which will match ANYTHING. So if it finds a 9, followed ANYWHERE on the line by a d, that would match and probably not do what you intended. Of course, in unix, that "." is also problematic unless you quote it (\.) since . matches any single character in regular-expression parlance...

Not sure about windows, but "*" is generally NOT what you want when doing search and replace.
You know not whole world is UNIX. Notepad++ regular expressions use the standard PCRE (Perl) syntax not POSIX as in UNIX.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: How I can in texteditor (notepad++) ... need help!

Post by bob »

Milos wrote:
bob wrote:In my unix world that won't work. 9.*d could match a d in move 10, since 9.* is a regular expression which will match ANYTHING. So if it finds a 9, followed ANYWHERE on the line by a d, that would match and probably not do what you intended. Of course, in unix, that "." is also problematic unless you quote it (\.) since . matches any single character in regular-expression parlance...

Not sure about windows, but "*" is generally NOT what you want when doing search and replace.
You know not whole world is UNIX. Notepad++ regular expressions use the standard PCRE (Perl) syntax not POSIX as in UNIX.
If they want to use oddball definitions of regular expressions, I don't care. I was simply pointing out a potential problem if it interpreted regular expressions in a standard way.
Adam Hair
Posts: 3226
Joined: Wed May 06, 2009 10:31 pm
Location: Fuquay-Varina, North Carolina

Re: How I can in texteditor (notepad++) ... need help!

Post by Adam Hair »

bob wrote:
Adam Hair wrote:
Hi Frank,

I am out of practice and I do not have a computer to experiment with, but may be this will work for you:

Find: (9.*)d
Replace: \1a

The parentheses groups together the characters corresponding to 9.*. \1 references the first group in the regular expression, allowing it in this case to remain unchanged.

Hope this works for you.
In my unix world that won't work. 9.*d could match a d in move 10, since 9.* is a regular expression which will match ANYTHING. So if it finds a 9, followed ANYWHERE on the line by a d, that would match and probably not do what you intended. Of course, in unix, that "." is also problematic unless you quote it (\.) since . matches any single character in regular-expression parlance...

Not sure about windows, but "*" is generally NOT what you want when doing search and replace.
I understand. The answer I gave Frank takes advantage of the format of his text file and it is not a general solution.
Milos
Posts: 4190
Joined: Wed Nov 25, 2009 1:47 am

Re: How I can in texteditor (notepad++) ... need help!

Post by Milos »

bob wrote:If they want to use oddball definitions of regular expressions, I don't care. I was simply pointing out a potential problem if it interpreted regular expressions in a standard way.
That you haven't heard of something doesn't make it oddball. It just shows your own susceptibility to limitation. There is not only one standard for regular expression no matter how hard is for you to see that. Beside POSIX there is also PCRE standard which is much more powerful than 20+ years old POSIX and many modern languages such as Java, JavaScript, Python, Ruby, Microsoft's .NET Framework, and XML Schema use its flavour.
Milos
Posts: 4190
Joined: Wed Nov 25, 2009 1:47 am

Re: How I can in texteditor (notepad++) ... need help!

Post by Milos »

Adam Hair wrote:I understand. The answer I gave Frank takes advantage of the format of his text file and it is not a general solution.
Your answer is perfectly correct and is general solution for Frank's problem for PCRE based regular expression matching. That Bob didn't hear about it is his fault.
Last edited by Milos on Fri Oct 21, 2016 2:04 am, edited 1 time in total.
Adam Hair
Posts: 3226
Joined: Wed May 06, 2009 10:31 pm
Location: Fuquay-Varina, North Carolina

Re: How I can in texteditor (notepad++) ... need help!

Post by Adam Hair »

Frank Quisinsky wrote:Adam,

shortly ...
It works exactly with the information you gave!

Now, what can I do for you?

I am very happy about it.

Best
Frank
Just keep up your good work, Frank.