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

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Frank Quisinsky
Posts: 6808
Joined: Wed Nov 18, 2009 7:16 pm
Location: Gutweiler, Germany
Full name: Frank Quisinsky

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

Post by Frank Quisinsky »

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
User avatar
yurikvelo
Posts: 710
Joined: Sat Dec 06, 2014 1:53 pm

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

Post by yurikvelo »

You want to find:

1) Search only within lines starting with two characters: "9."
2) Search for 3 characters " d " (space, d, space) and replace them with " a " (space, a, space)

I would do this in 2 steps:
1) `grep (unix or UnixTools for win32 utility) lines containing "9." in separate file, e.g. "9m.txt"
2) replace " d " to " a " in "9m.txt" without regexp
3) merge "9m.txt" back to big file

`grep "9-" big_file.txt > 9m.txt
`grep -v "9-" big_file.txt > big_except_9m.txt
pferd
Posts: 134
Joined: Thu Jul 24, 2014 2:49 pm

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

Post by pferd »

I did not completely understand your requirements but I came up with this solution on linux. All 'd's between '9-' and ';' are replaced by an a.

Code: Select all

hermann@brutus ~/Downloads % cat test.txt 
7- F8E8 a B2B3 a C8G4 a H2H3 d G4F3 a D1F3 a B8D7 a F3E2 d D8A5 a A2A3 a A5A6 d ; 
9- G4H5 a G3G4 d H5G6 a F3H4 a D6B4 d E4D5 a C6D5 a ; 
9- G4H5 a G3G4 a H5G6 a F3H4 d D6B4 d E4D5 a C6D5 d ; 
hermann@brutus ~/Downloads % sed -i.bak '/9-/,/;/s/d/a/g' test.txt
hermann@brutus ~/Downloads % cat test.txt
7- F8E8 a B2B3 a C8G4 a H2H3 d G4F3 a D1F3 a B8D7 a F3E2 d D8A5 a A2A3 a A5A6 d ; 
9- G4H5 a G3G4 a H5G6 a F3H4 a D6B4 a E4D5 a C6D5 a ; 
9- G4H5 a G3G4 a H5G6 a F3H4 a D6B4 a E4D5 a C6D5 a ; 
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: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.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

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

Post by Sven »

Frank Quisinsky wrote:Now I will replace in these lines d only with ... a
Should be easy with Notepad++. Select "Normal" under "Search mode", then "Match whole word only", then enter just the letter "d" in the field "Find what:" and "a" in "Replace with:". Finally click the button "Replace all". No regular expressions needed and no external scripts (although both would be possible as well).
User avatar
yurikvelo
Posts: 710
Joined: Sat Dec 06, 2014 1:53 pm

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

Post by yurikvelo »

Sven Schüle wrote:
Frank Quisinsky wrote:Now I will replace in these lines d only with ... a
Should be easy with Notepad++. Select "Normal" under "Search mode", then "Match whole word only", then enter just the letter "d" in the field "Find what:" and "a" in "Replace with:". Finally click the button "Replace all". No regular expressions needed and no external scripts (although both would be possible as well).
Lines starting at any character except 9 should be ignored
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

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

Post by Sven »

yurikvelo wrote:
Sven Schüle wrote:
Frank Quisinsky wrote:Now I will replace in these lines d only with ... a
Should be easy with Notepad++. Select "Normal" under "Search mode", then "Match whole word only", then enter just the letter "d" in the field "Find what:" and "a" in "Replace with:". Finally click the button "Replace all". No regular expressions needed and no external scripts (although both would be possible as well).
Lines starting at any character except 9 should be ignored
Ok, that was not clear for me from the description. In that case Notepad++ may be the wrong tool.
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 »

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
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 »

Hello Herrmann and Youri,

yes, that is exactly what I need (example with Linux).
I will try it out in detail later in the evening. If I have again problems, I can send my book in txt format.

In the past main parts from my book ended with move 6, later with move 8 or 10 and on the end of the line Shredder set "d".

But "d" is also the lowest priority for book moves (a, the highest, b, c, d). So the letter "d" have two meanings.

- lowest priority and
- end of the line

And this is bad for my intern stats. I can not see how many b, c, d ...

I think my problem is solved now.

With the parameter Adam sent I can perfectly replace in lines after move 6, 8, 10 the "d" with "a". Furthermore, I set on the end of the line "a" too and all problems are solved.

Thanks again!

Best
Frank
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 Sven,

I am a Notepad++ fan since many years but yesterday in the evening I found not the right parameter.

I can't set all "d" to "a".
Because "d" have two meanings, is also the lowest priority.

If I do that ...
1. e4 have the same priority (is at the moment "a") as 1. b4 (is at the moment "d").

That is bad ...
Shredder GUI set ... after I create a text format from my book ... the "d" to the end of the lines. In the last years I made some extensions and I have between a main line after move 6, 8, 10 the "d" and not the right "a". Over 13.000 from around 86.000 lines in my book ... I have the wrong letter in the book. OK for the book not important ... all lines can be play but this is a blemish. Also bad for intern stats. Can not see in Detail how many lines have a low priority with "d" if "d" is also end of the line. And after all my extensions a lot of lines ended today (current Version) not with move 6, 8, 10 ... ended with move 12 and I have so many wrong "d" in my book ... again in the middle of a 12 move line.

I don't like the letter "d" after three hours I try to find the right parameter yesterday in the evening and go to bed ... shit "d" ... sorry!

Thanks to all ...
An opening book update will be today in the late evening available. I will added the textfile for looking.

Best and thanks
Frank

And all that in my bad English.
I think no one can follow what I mean here ... but the parameter Adam posted is perfect and I can solve my problem!