Date   

Re: Selecting all text between blank lines

Ian Rastall
 

My apologies. I completely misunderstood. I thought that was a joke meant
to erase the file, assuming I was working with temp text. With my limited
knowledge I thought with the use of the >> then whatever was in-between the
second set of quotes (i.e. nothing) was what the replace text was. I didn't
try it for that reason.

On Tue, Jan 25, 2022 at 8:39 AM Flo <flo.gehrke@t-online.de> wrote:

Ian wrote...

> I appreciated this one:
>; Change all movelists to one-liners in one go
>^!Replace "(?:\R(?<=\])|\R(?=\R|[1\[]))(*SKIP)(*F)|\R" >> " " rwas

When testing your clip against the movelines you posted in message
#26331 then - due to a lot of backtracking - the engine needs thousands
of steps but doesn't remove all CRNL inside that block for me.

I suppose your SKIP/FAIL subpattern is ment to leave the headers
untouched. Why don't you try a Negative Lookahead that skips all lines
starting with a left square bracket:

^!Replace "^(?!\[)[^\r\n]++\K\R(?!\R)" >> "\x20" WARS

This would remove all CRNL in a single block of movelines needing much
less steps.

See a demo with reduced data https://regex101.com/r/nEWV1F/1

Regards,
Flo

Breaking down the RegEx

^= start of line
(?!\[) = Negative Lookahead, no bracket following at the next position
[^\r\n]++ = Character Class, any character that is no CRNL, one or more,
with possessive quantifier in order to avoid unnecessary
backtracking
\K = reset of match discarding what has been matched so far
\R = CRNL
(?!\R) = Negative Lookahead, no second CRNL following
\x20 = Replace string, a space in hex







Re: Selecting all text between blank lines

Ian Rastall
 

I appreciated this one:

; Change all movelists to one-liners in one go
^!Replace "(?:\R(?<=\])|\R(?=\R|[1\[]))(*SKIP)(*F)|\R" >> " " rwas
^!Jump 1

:-)


Re: Selecting all text between blank lines

m.feichtinger
 

You are welcome.

My first posting was also okay, but Thunderbird showed caret 1 '^1' as
footnote <sup>1</sup> and I thought it was an error on my part.

All the best,
Markus

Am 2022-01-24 um 12:28 schrieb Ian Rastall:

Okay, that's the one that did it. I had it worked out to do one at a time,
but having just seen this scroll through about 1,500 records in a minute,
that was awesome. Thank you very much.

On Mon, Jan 24, 2022 at 5:10 AM m.feichtinger <mafei@gmx.at> wrote:

Sorry, still wrong: 1. at the beginning of line should be regex ^%CARET%1\.

^!Find "(?si)^%CARET%1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError end
^!Menu Modify / Lines / Join Lines

If you want to change all movelists to one-liners in one go then:

^!Jump 1
^!Find "(?si)^%CARET%1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError Done
^!Menu Modify / Lines / Join Lines
^!Goto skip_-3
:Done
^!Jump 1

HTH

Am 2022-01-24 um 00:56 schrieb Ian Rastall:
Hi again. In building a clip library to work with PGNs (chess notation
files) I've run into a second problem I can't figure out. Each of them is
twoblocks of text. The headers, which we'd been futzing with (and thank
you) and the movelist, which is word-wrapped to 75.

Each record (and they too are separated by blank lines) looks like this:

[Event "Russian Women's Championship Superfinal 2021"]
[Site "Ufa RUS"]
[Date "2021.10.09"]
[Round "1.1"]
[White "Shuvalova, Polina"]
[Black "Ovod, Evgenija"]
[Result "1/2-1/2"]
[EventDate "2021.10.08"]
[ECO "C67"]
[WhiteElo "2509"]
[BlackElo "2331"]
[PlyCount "104"]

1.e4 e5 2.Nf3 Nc6 3.Bb5 Nf6 4.O-O Nxe4 5.d4 Be7 6.Qe2 Nd6 7.Bxc6 bxc6 8.
dxe5 Nb7 9.c4 O-O 10.Nc3 f6 11.Re1 Nc5 12.Bf4 Ne6 13.exf6 Bxf6 14.Bg3
Bxc3
15.bxc3 d6 16.c5 Nxc5 17.Qc4+ Kh8 18.Bh4 Qd7 19.Rad1 Qg4 20.Qd4 Qxd4 21.
cxd4 Ne6 22.Ng5 Nf4 23.Bg3 Nd5 24.f3 Bd7 25.Rd3 a5 26.Ra3 Rfb8 27.Ne4 Rb2
28.Rd1 Kg8 29.Rd2 Rxd2 30.Nxd2 a4 31.Ne4 h6 32.Be1 Kf7 33.Kf2 Be6 34.Rd3
a3 35.Bd2 Nb6 36.Bb4 Bxa2 37.Rxa3 Rxa3 38.Bxa3 Ke6 39.Nc3 Bb3 40.Bc1 Nd7
41.Ba3 Nf8 42.Ke3 Ng6 43.g3 Bc4 44.Bb4 Ne7 45.g4 Nd5+ 46.Nxd5 cxd5 47.f4
g6 48.Ba5 c6 49.Bb4 Bb3 50.Ke2 Bc2 51.Kd2 Be4 52.Ke3 1/2-1/2

Eventually it became clear that the movelist needed to be one line. With
the clip I use now, I select the paragraph, and run these two lines:

^!Keyboard CTRL+J
^!Keyboard RIGHT

(The second line is there to keep the cursor from ending up way off to
the right, instead putting it in-between records. It doesn't work with the
last record, as there's no last line in the document.)

Right now my goal has been to be able to place the cursor anywhere in
theparagraph, and the clip would select between the blank lines and then
jointhe paragraph and put the cursor on the blank line between records. The
search terms are as follows: each movelist begins with 1. and always ends
with either 1-0 or 0-1 or 1/2-1/2, in all instances.

RegExp has always confused me. I couldn't find something for a blank
line. I'm sure it's right there. I was think ^$ would be all I'd need, as
that's a line with nothing between the beginning and end. That might not be
the most logical search pattern.:-) My idea was, search for a blank line,
thenthe next one, then select everything in-between and do ^!Keyboard with
CTRL-J and RIGHT. It's the line breaks that keep it from working, though.
Using^!Select PARAGRAPHS, or the singular version, just selects the line.

Thank you in advance for any and all help.


Re: Selecting all text between blank lines

Axel Berger
 

Ian Rastall wrote:
^!Find "^P^P" S
^!Keyboard LEFT LEFT
^!SelectTo :0
For your current cursor position you have ^$GetCol$ and ^$GetRow$. Save
those into variables and use them in your final ^!SelectTo


--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
 X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --


Re: Selecting all text between blank lines

Don Passenger
 

If you back up then find block you want you can select it.

You can also use getrow for cursor position.

On Mon, Jan 24, 2022, 12:33 AM Ian Rastall <moving.form.of.dust@gmail.com>
wrote:

This will probably be too specific to ever be of use in a Google search,
but nonetheless, the kludge I decided on is this:

^!Keyboard CTRL+J
^!Keyboard RIGHT
^!Find "^P^P" S
^!Find "^P^P" S

I have to select the movelist first, but then, with the selection, it does
what I need, unselects, essentially, and then moves down two blank lines,
so the next movelist is at the bottom of the screen ready to be selected.
It makes it a pretty easy task. I'm glad for the help that you guys gave
me, especially figuring out what must have been too simple a request: to
get to blank lines. :-)






Re: Selecting all text between blank lines

Don Passenger
 

That depends on switches, yes? If you start mid document as he suggested,
regex will not go backwards. If you do the entire document then I agree.

On Sun, Jan 23, 2022, 10:21 PM John Shotsky <jshotsky@comcast.net> wrote:

Actually, it does search the whole document. Not searching backwards at
all. Does not matter, the regex does what is requested. When you make a
'global' change like this, it does not search only downward.
Regards,
John

-----Original Message-----
From: Clips@Notetab.groups.io <Clips@Notetab.groups.io> On Behalf Of Don
Passenger
Sent: Sunday, January 23, 2022 6:28 PM
To: Clips@notetab.groups.io
Subject: Re: [NTB-Clps] Selecting all text between blank lines

I agree with this. One problem however is you suggest that you are
searching backwards (want to start anywhere) which regex won't do for you.
First search backwards for ^P^P with un-regex then apply the regex to the
block going forward.

On Sun, Jan 23, 2022, 7:32 PM John Shotsky <jshotsky@comcast.net> wrote:

I agree with this, except I do it this way:
\R\R+
In case there are more than one blank line present. In my work, that
often happens.
The reason \R is best is that there are different ways a line end is
handled by different operating system - windows, Unix and Apple are
all different. \R works for all of them.
In fact, when I first open any new doc, the first thing I do is
replace \R with \r\n, so I KNOW I have the Windows CRLF throughout.

Regards,
John

-----Original Message-----
From: Clips@Notetab.groups.io <Clips@Notetab.groups.io> On Behalf Of
Axel Berger
Sent: Sunday, January 23, 2022 4:15 PM
To: Clips@Notetab.groups.io
Subject: Re: [NTB-Clps] Selecting all text between blank lines

Alex Plantema wrote:
\n\r can be used to find a blank line.
Better \R and for a blank line you need \R\R.


--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --




















Re: Selecting all text between blank lines

Ian Rastall
 

Okay, that's the one that did it. I had it worked out to do one at a time,
but having just seen this scroll through about 1,500 records in a minute,
that was awesome. Thank you very much.

On Mon, Jan 24, 2022 at 5:10 AM m.feichtinger <mafei@gmx.at> wrote:

Sorry, still wrong: 1. at the beginning of line should be regex ^%CARET%1\.

^!Find "(?si)^%CARET%1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError end
^!Menu Modify / Lines / Join Lines

If you want to change all movelists to one-liners in one go then:

^!Jump 1
^!Find "(?si)^%CARET%1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError Done
^!Menu Modify / Lines / Join Lines
^!Goto skip_-3
:Done
^!Jump 1

HTH

Am 2022-01-24 um 00:56 schrieb Ian Rastall:
Hi again. In building a clip library to work with PGNs (chess notation
files) I've run into a second problem I can't figure out. Each of them is
twoblocks of text. The headers, which we'd been futzing with (and thank
you) and the movelist, which is word-wrapped to 75.

Each record (and they too are separated by blank lines) looks like this:

[Event "Russian Women's Championship Superfinal 2021"]
[Site "Ufa RUS"]
[Date "2021.10.09"]
[Round "1.1"]
[White "Shuvalova, Polina"]
[Black "Ovod, Evgenija"]
[Result "1/2-1/2"]
[EventDate "2021.10.08"]
[ECO "C67"]
[WhiteElo "2509"]
[BlackElo "2331"]
[PlyCount "104"]

1.e4 e5 2.Nf3 Nc6 3.Bb5 Nf6 4.O-O Nxe4 5.d4 Be7 6.Qe2 Nd6 7.Bxc6 bxc6 8.
dxe5 Nb7 9.c4 O-O 10.Nc3 f6 11.Re1 Nc5 12.Bf4 Ne6 13.exf6 Bxf6 14.Bg3
Bxc3
15.bxc3 d6 16.c5 Nxc5 17.Qc4+ Kh8 18.Bh4 Qd7 19.Rad1 Qg4 20.Qd4 Qxd4 21.
cxd4 Ne6 22.Ng5 Nf4 23.Bg3 Nd5 24.f3 Bd7 25.Rd3 a5 26.Ra3 Rfb8 27.Ne4 Rb2
28.Rd1 Kg8 29.Rd2 Rxd2 30.Nxd2 a4 31.Ne4 h6 32.Be1 Kf7 33.Kf2 Be6 34.Rd3
a3 35.Bd2 Nb6 36.Bb4 Bxa2 37.Rxa3 Rxa3 38.Bxa3 Ke6 39.Nc3 Bb3 40.Bc1 Nd7
41.Ba3 Nf8 42.Ke3 Ng6 43.g3 Bc4 44.Bb4 Ne7 45.g4 Nd5+ 46.Nxd5 cxd5 47.f4
g6 48.Ba5 c6 49.Bb4 Bb3 50.Ke2 Bc2 51.Kd2 Be4 52.Ke3 1/2-1/2

Eventually it became clear that the movelist needed to be one line. With
the clip I use now, I select the paragraph, and run these two lines:

^!Keyboard CTRL+J
^!Keyboard RIGHT

(The second line is there to keep the cursor from ending up way off to
the right, instead putting it in-between records. It doesn't work with the
last record, as there's no last line in the document.)

Right now my goal has been to be able to place the cursor anywhere in
theparagraph, and the clip would select between the blank lines and then
jointhe paragraph and put the cursor on the blank line between records. The
search terms are as follows: each movelist begins with 1. and always ends
with either 1-0 or 0-1 or 1/2-1/2, in all instances.

RegExp has always confused me. I couldn't find something for a blank
line. I'm sure it's right there. I was think ^$ would be all I'd need, as
that's a line with nothing between the beginning and end. That might not be
the most logical search pattern.:-) My idea was, search for a blank line,
thenthe next one, then select everything in-between and do ^!Keyboard with
CTRL-J and RIGHT. It's the line breaks that keep it from working, though.
Using^!Select PARAGRAPHS, or the singular version, just selects the line.

Thank you in advance for any and all help.















Re: Selecting all text between blank lines

m.feichtinger
 

Sorry, still wrong: 1. at the beginning of line should be regex ^%CARET%1\.

^!Find "(?si)^%CARET%1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError end
^!Menu Modify / Lines / Join Lines

If you want to change all movelists to one-liners in one go then:

^!Jump 1
^!Find "(?si)^%CARET%1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError Done
^!Menu Modify / Lines / Join Lines
^!Goto skip_-3
:Done
^!Jump 1

HTH

Am 2022-01-24 um 00:56 schrieb Ian Rastall:

Hi again. In building a clip library to work with PGNs (chess notation files) I've run into a second problem I can't figure out. Each of them is twoblocks of text. The headers, which we'd been futzing with (and thank you) and the movelist, which is word-wrapped to 75.

Each record (and they too are separated by blank lines) looks like this:

[Event "Russian Women's Championship Superfinal 2021"]
[Site "Ufa RUS"]
[Date "2021.10.09"]
[Round "1.1"]
[White "Shuvalova, Polina"]
[Black "Ovod, Evgenija"]
[Result "1/2-1/2"]
[EventDate "2021.10.08"]
[ECO "C67"]
[WhiteElo "2509"]
[BlackElo "2331"]
[PlyCount "104"]

1.e4 e5 2.Nf3 Nc6 3.Bb5 Nf6 4.O-O Nxe4 5.d4 Be7 6.Qe2 Nd6 7.Bxc6 bxc6 8.
dxe5 Nb7 9.c4 O-O 10.Nc3 f6 11.Re1 Nc5 12.Bf4 Ne6 13.exf6 Bxf6 14.Bg3 Bxc3
15.bxc3 d6 16.c5 Nxc5 17.Qc4+ Kh8 18.Bh4 Qd7 19.Rad1 Qg4 20.Qd4 Qxd4 21.
cxd4 Ne6 22.Ng5 Nf4 23.Bg3 Nd5 24.f3 Bd7 25.Rd3 a5 26.Ra3 Rfb8 27.Ne4 Rb2
28.Rd1 Kg8 29.Rd2 Rxd2 30.Nxd2 a4 31.Ne4 h6 32.Be1 Kf7 33.Kf2 Be6 34.Rd3
a3 35.Bd2 Nb6 36.Bb4 Bxa2 37.Rxa3 Rxa3 38.Bxa3 Ke6 39.Nc3 Bb3 40.Bc1 Nd7
41.Ba3 Nf8 42.Ke3 Ng6 43.g3 Bc4 44.Bb4 Ne7 45.g4 Nd5+ 46.Nxd5 cxd5 47.f4
g6 48.Ba5 c6 49.Bb4 Bb3 50.Ke2 Bc2 51.Kd2 Be4 52.Ke3 1/2-1/2

Eventually it became clear that the movelist needed to be one line. With the clip I use now, I select the paragraph, and run these two lines:

^!Keyboard CTRL+J
^!Keyboard RIGHT

(The second line is there to keep the cursor from ending up way off to the right, instead putting it in-between records. It doesn't work with the last record, as there's no last line in the document.)

Right now my goal has been to be able to place the cursor anywhere in theparagraph, and the clip would select between the blank lines and then jointhe paragraph and put the cursor on the blank line between records. The search terms are as follows: each movelist begins with 1. and always ends with either 1-0 or 0-1 or 1/2-1/2, in all instances.

RegExp has always confused me. I couldn't find something for a blank line. I'm sure it's right there. I was think ^$ would be all I'd need, as that's a line with nothing between the beginning and end. That might not be the most logical search pattern.:-) My idea was, search for a blank line, thenthe next one, then select everything in-between and do ^!Keyboard with CTRL-J and RIGHT. It's the line breaks that keep it from working, though. Using^!Select PARAGRAPHS, or the singular version, just selects the line.

Thank you in advance for any and all help.


Re: Selecting all text between blank lines

m.feichtinger
 

Sorry, should be 1. as regex 1\.

^!Find "(?si)1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError end
^!Menu Modify / Lines / Join Lines

If you want to change all movelists to one-liners in one go then:

^!Jump 1
^!Find "(?si)1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError Done
^!Menu Modify / Lines / Join Lines
^!Goto skip_-3
:Done
^!Jump 1

HTH

Am 2022-01-24 um 00:56 schrieb Ian Rastall:

Hi again. In building a clip library to work with PGNs (chess notation files) I've run into a second problem I can't figure out. Each of them is twoblocks of text. The headers, which we'd been futzing with (and thank you) and the movelist, which is word-wrapped to 75.

Each record (and they too are separated by blank lines) looks like this:

[Event "Russian Women's Championship Superfinal 2021"]
[Site "Ufa RUS"]
[Date "2021.10.09"]
[Round "1.1"]
[White "Shuvalova, Polina"]
[Black "Ovod, Evgenija"]
[Result "1/2-1/2"]
[EventDate "2021.10.08"]
[ECO "C67"]
[WhiteElo "2509"]
[BlackElo "2331"]
[PlyCount "104"]

1.e4 e5 2.Nf3 Nc6 3.Bb5 Nf6 4.O-O Nxe4 5.d4 Be7 6.Qe2 Nd6 7.Bxc6 bxc6 8.
dxe5 Nb7 9.c4 O-O 10.Nc3 f6 11.Re1 Nc5 12.Bf4 Ne6 13.exf6 Bxf6 14.Bg3 Bxc3
15.bxc3 d6 16.c5 Nxc5 17.Qc4+ Kh8 18.Bh4 Qd7 19.Rad1 Qg4 20.Qd4 Qxd4 21.
cxd4 Ne6 22.Ng5 Nf4 23.Bg3 Nd5 24.f3 Bd7 25.Rd3 a5 26.Ra3 Rfb8 27.Ne4 Rb2
28.Rd1 Kg8 29.Rd2 Rxd2 30.Nxd2 a4 31.Ne4 h6 32.Be1 Kf7 33.Kf2 Be6 34.Rd3
a3 35.Bd2 Nb6 36.Bb4 Bxa2 37.Rxa3 Rxa3 38.Bxa3 Ke6 39.Nc3 Bb3 40.Bc1 Nd7
41.Ba3 Nf8 42.Ke3 Ng6 43.g3 Bc4 44.Bb4 Ne7 45.g4 Nd5+ 46.Nxd5 cxd5 47.f4
g6 48.Ba5 c6 49.Bb4 Bb3 50.Ke2 Bc2 51.Kd2 Be4 52.Ke3 1/2-1/2

Eventually it became clear that the movelist needed to be one line. With the clip I use now, I select the paragraph, and run these two lines:

^!Keyboard CTRL+J
^!Keyboard RIGHT

(The second line is there to keep the cursor from ending up way off to the right, instead putting it in-between records. It doesn't work with the last record, as there's no last line in the document.)

Right now my goal has been to be able to place the cursor anywhere in theparagraph, and the clip would select between the blank lines and then jointhe paragraph and put the cursor on the blank line between records. The search terms are as follows: each movelist begins with 1. and always ends with either 1-0 or 0-1 or 1/2-1/2, in all instances.

RegExp has always confused me. I couldn't find something for a blank line. I'm sure it's right there. I was think ^$ would be all I'd need, as that's a line with nothing between the beginning and end. That might not be the most logical search pattern.:-) My idea was, search for a blank line, thenthe next one, then select everything in-between and do ^!Keyboard with CTRL-J and RIGHT. It's the line breaks that keep it from working, though. Using ^!Select PARAGRAPHS, or the singular version, just selects the line.

Thank you in advance for any and all help.


Re: Selecting all text between blank lines

m.feichtinger
 

Ooops, a typo, this is correct:

^!Find "(?si)\..+?(?:\R(?=\R+)|\z)" rs
^!IfError end
^!Menu Modify / Lines / Join Lines

If you want to change all movelists to one-liners in one go then:

^!Jump 1
^!Find "(?si)\..+?(?:\R(?=\R+)|\z)" rs
^!IfError Done
^!Menu Modify / Lines / Join Lines
^!Goto skip_-3
:Done
^!Jump 1

HTH

Am 2022-01-24 um 00:56 schrieb Ian Rastall:

Hi again. In building a clip library to work with PGNs (chess notation files) I've run into a second problem I can't figure out. Each of them is two blocks of text. The headers, which we'd been futzing with (and thank you) and the movelist, which is word-wrapped to 75.

Each record (and they too are separated by blank lines) looks like this:

[Event "Russian Women's Championship Superfinal 2021"]
[Site "Ufa RUS"]
[Date "2021.10.09"]
[Round "1.1"]
[White "Shuvalova, Polina"]
[Black "Ovod, Evgenija"]
[Result "1/2-1/2"]
[EventDate "2021.10.08"]
[ECO "C67"]
[WhiteElo "2509"]
[BlackElo "2331"]
[PlyCount "104"]

1.e4 e5 2.Nf3 Nc6 3.Bb5 Nf6 4.O-O Nxe4 5.d4 Be7 6.Qe2 Nd6 7.Bxc6 bxc6 8.
dxe5 Nb7 9.c4 O-O 10.Nc3 f6 11.Re1 Nc5 12.Bf4 Ne6 13.exf6 Bxf6 14.Bg3 Bxc3
15.bxc3 d6 16.c5 Nxc5 17.Qc4+ Kh8 18.Bh4 Qd7 19.Rad1 Qg4 20.Qd4 Qxd4 21.
cxd4 Ne6 22.Ng5 Nf4 23.Bg3 Nd5 24.f3 Bd7 25.Rd3 a5 26.Ra3 Rfb8 27.Ne4 Rb2
28.Rd1 Kg8 29.Rd2 Rxd2 30.Nxd2 a4 31.Ne4 h6 32.Be1 Kf7 33.Kf2 Be6 34.Rd3
a3 35.Bd2 Nb6 36.Bb4 Bxa2 37.Rxa3 Rxa3 38.Bxa3 Ke6 39.Nc3 Bb3 40.Bc1 Nd7
41.Ba3 Nf8 42.Ke3 Ng6 43.g3 Bc4 44.Bb4 Ne7 45.g4 Nd5+ 46.Nxd5 cxd5 47.f4
g6 48.Ba5 c6 49.Bb4 Bb3 50.Ke2 Bc2 51.Kd2 Be4 52.Ke3 1/2-1/2

Eventually it became clear that the movelist needed to be one line. With the clip I use now, I select the paragraph, and run these two lines:

^!Keyboard CTRL+J
^!Keyboard RIGHT

(The second line is there to keep the cursor from ending up way off to the right, instead putting it in-between records. It doesn't work with the last record, as there's no last line in the document.)

Right now my goal has been to be able to place the cursor anywhere in the paragraph, and the clip would select between the blank lines and then join the paragraph and put the cursor on the blank line between records. The search terms are as follows: each movelist begins with 1. and always ends with either 1-0 or 0-1 or 1/2-1/2, in all instances.

RegExp has always confused me. I couldn't find something for a blank line. I'm sure it's right there. I was think ^$ would be all I'd need, as that's a line with nothing between the beginning and end. That might not be the most logical search pattern.:-) My idea was, search for a blank line, then the next one, then select everything in-between and do ^!Keyboard with CTRL-J and RIGHT. It's the line breaks that keep it from working, though. Using ^!Select PARAGRAPHS, or the singular version, just selects the line.

Thank you in advance for any and all help.


Re: Selecting all text between blank lines

m.feichtinger
 

^!Find "(?si)^1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError end
^!Menu Modify / Lines / Join Lines

If you want to change all movelists to one-liners in one go then:

^!Jump 1
^!Find "(?si)^1\..+?(?:\R(?=\R+)|\z)" rs
^!IfError Done
^!Menu Modify / Lines / Join Lines
^!Goto skip_-3
:Done
^!Jump 1

HTH

Am 2022-01-24 um 00:56 schrieb Ian Rastall:

Hi again. In building a clip library to work with PGNs (chess notation files) I've run into a second problem I can't figure out. Each of them is two blocks of text. The headers, which we'd been futzing with (and thank you) and the movelist, which is word-wrapped to 75.

Each record (and they too are separated by blank lines) looks like this:

[Event "Russian Women's Championship Superfinal 2021"]
[Site "Ufa RUS"]
[Date "2021.10.09"]
[Round "1.1"]
[White "Shuvalova, Polina"]
[Black "Ovod, Evgenija"]
[Result "1/2-1/2"]
[EventDate "2021.10.08"]
[ECO "C67"]
[WhiteElo "2509"]
[BlackElo "2331"]
[PlyCount "104"]

1.e4 e5 2.Nf3 Nc6 3.Bb5 Nf6 4.O-O Nxe4 5.d4 Be7 6.Qe2 Nd6 7.Bxc6 bxc6 8.
dxe5 Nb7 9.c4 O-O 10.Nc3 f6 11.Re1 Nc5 12.Bf4 Ne6 13.exf6 Bxf6 14.Bg3 Bxc3
15.bxc3 d6 16.c5 Nxc5 17.Qc4+ Kh8 18.Bh4 Qd7 19.Rad1 Qg4 20.Qd4 Qxd4 21.
cxd4 Ne6 22.Ng5 Nf4 23.Bg3 Nd5 24.f3 Bd7 25.Rd3 a5 26.Ra3 Rfb8 27.Ne4 Rb2
28.Rd1 Kg8 29.Rd2 Rxd2 30.Nxd2 a4 31.Ne4 h6 32.Be1 Kf7 33.Kf2 Be6 34.Rd3
a3 35.Bd2 Nb6 36.Bb4 Bxa2 37.Rxa3 Rxa3 38.Bxa3 Ke6 39.Nc3 Bb3 40.Bc1 Nd7
41.Ba3 Nf8 42.Ke3 Ng6 43.g3 Bc4 44.Bb4 Ne7 45.g4 Nd5+ 46.Nxd5 cxd5 47.f4
g6 48.Ba5 c6 49.Bb4 Bb3 50.Ke2 Bc2 51.Kd2 Be4 52.Ke3 1/2-1/2

Eventually it became clear that the movelist needed to be one line. With the clip I use now, I select the paragraph, and run these two lines:

^!Keyboard CTRL+J
^!Keyboard RIGHT

(The second line is there to keep the cursor from ending up way off to the right, instead putting it in-between records. It doesn't work with the last record, as there's no last line in the document.)

Right now my goal has been to be able to place the cursor anywhere in the paragraph, and the clip would select between the blank lines and then join the paragraph and put the cursor on the blank line between records. The search terms are as follows: each movelist begins with 1. and always ends with either 1-0 or 0-1 or 1/2-1/2, in all instances.

RegExp has always confused me. I couldn't find something for a blank line. I'm sure it's right there. I was think ^$ would be all I'd need, as that's a line with nothing between the beginning and end. That might not be the most logical search pattern.:-) My idea was, search for a blank line, then the next one, then select everything in-between and do ^!Keyboard with CTRL-J and RIGHT. It's the line breaks that keep it from working, though. Using ^!Select PARAGRAPHS, or the singular version, just selects the line.

Thank you in advance for any and all help.


Re: Selecting all text between blank lines

Ian Rastall
 

This will probably be too specific to ever be of use in a Google search, but nonetheless, the kludge I decided on is this:

^!Keyboard CTRL+J
^!Keyboard RIGHT
^!Find "^P^P" S
^!Find "^P^P" S

I have to select the movelist first, but then, with the selection, it does what I need, unselects, essentially, and then moves down two blank lines, so the next movelist is at the bottom of the screen ready to be selected. It makes it a pretty easy task. I'm glad for the help that you guys gave me, especially figuring out what must have been too simple a request: to get to blank lines. :-)


Re: Selecting all text between blank lines

Ian Rastall
 

Okay, I've gotten it worked out to something simple. Except it isn't. There doesn't seem to be a way to say, select from cursor position to this position that you can find by searching for 1. ... It looks like this right now:

^!Find "^P^P" S
^!Keyboard LEFT LEFT
^!SelectTo :0

I don't know what to put before the :0 ... If it were possible to do ^!GetRow("1.") then that would be that.

So, the way it is, I put the cursor anywhere in the move list. It goes forward to the next blank line, lands at col 0 on the next line. So I need to then go backwards two spaces. That's all it does so far. It ignores the last command, as far as I know.


Re: Selecting all text between blank lines

John Shotsky
 

Actually, it does search the whole document. Not searching backwards at all. Does not matter, the regex does what is requested. When you make a 'global' change like this, it does not search only downward.
Regards,
John

-----Original Message-----
From: Clips@Notetab.groups.io <Clips@Notetab.groups.io> On Behalf Of Don Passenger
Sent: Sunday, January 23, 2022 6:28 PM
To: Clips@notetab.groups.io
Subject: Re: [NTB-Clps] Selecting all text between blank lines

I agree with this. One problem however is you suggest that you are searching backwards (want to start anywhere) which regex won't do for you.
First search backwards for ^P^P with un-regex then apply the regex to the block going forward.

On Sun, Jan 23, 2022, 7:32 PM John Shotsky <jshotsky@comcast.net> wrote:

I agree with this, except I do it this way:
\R\R+
In case there are more than one blank line present. In my work, that
often happens.
The reason \R is best is that there are different ways a line end is
handled by different operating system - windows, Unix and Apple are
all different. \R works for all of them.
In fact, when I first open any new doc, the first thing I do is
replace \R with \r\n, so I KNOW I have the Windows CRLF throughout.

Regards,
John

-----Original Message-----
From: Clips@Notetab.groups.io <Clips@Notetab.groups.io> On Behalf Of
Axel Berger
Sent: Sunday, January 23, 2022 4:15 PM
To: Clips@Notetab.groups.io
Subject: Re: [NTB-Clps] Selecting all text between blank lines

Alex Plantema wrote:
\n\r can be used to find a blank line.
Better \R and for a blank line you need \R\R.


--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --











Re: Selecting all text between blank lines

Don Passenger
 

I agree with this. One problem however is you suggest that you are
searching backwards (want to start anywhere) which regex won't do for you.
First search backwards for ^P^P with un-regex then apply the regex to the
block going forward.

On Sun, Jan 23, 2022, 7:32 PM John Shotsky <jshotsky@comcast.net> wrote:

I agree with this, except I do it this way:
\R\R+
In case there are more than one blank line present. In my work, that often
happens.
The reason \R is best is that there are different ways a line end is
handled by
different operating system - windows, Unix and Apple are all different. \R
works
for all of them.
In fact, when I first open any new doc, the first thing I do is replace \R
with
\r\n, so I KNOW I have the Windows CRLF throughout.

Regards,
John

-----Original Message-----
From: Clips@Notetab.groups.io <Clips@Notetab.groups.io> On Behalf Of Axel
Berger
Sent: Sunday, January 23, 2022 4:15 PM
To: Clips@Notetab.groups.io
Subject: Re: [NTB-Clps] Selecting all text between blank lines

Alex Plantema wrote:
\n\r can be used to find a blank line.
Better \R and for a blank line you need \R\R.


--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --











Re: Selecting all text between blank lines

Don Passenger
 

Use an or backslash R or backslash z which means end of file. Then you need
not insert the false line.

I used to be clueless on regex but I hung around here long enough that

A. I have trouble now using un-regex for searches

and

B. I actually make some $ writing regex

Point, don't give up.

I comment my regex with a before and after and then if something changes
like Joy suggested, easy to revise. Named captures also helps sort it.

On Sun, Jan 23, 2022, 7:13 PM Axel Berger <Axel@berger-odenthal.de> wrote:

Ian Rastall wrote:
It doesn't work with the last record, as there's no last line in
the document.)
Yes, that's a frequent problem. I often begin my clips with appending an
empty or a dummy line. If a dummy, you make delting it your last command.

This is an example where "sig:" is the beginning of the first line of every
block:

^!Jump TEXT_END
^!InsertText sig:
...
:loop
^!Find "(?s)^abs: (.*?)^sig:" HRS1
...
^!Jump TEXT_END
^!DeleteLine


--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --






Re: Selecting all text between blank lines

Don Passenger
 

Or backslash with a capital R
\R

On Sun, Jan 23, 2022, 7:03 PM Alex Plantema <alex.plantema@xs4all.nl> wrote:

Op ma 24-01-2022 om 00:56 schreef Ian Rastall:
RegExp has always confused me. I couldn't find something for a blank
line. I'm sure it's right there. I was think ^$ would be all I'd need, as
that's a line with nothing between the beginning and end. That might not be
the most logical search pattern. :-) My idea was, search for a blank line,
then the next one, then select everything in-between and do ^!Keyboard with
CTRL-J and RIGHT. It's the line breaks that keep it from working, though.
Using ^!Select PARAGRAPHS, or the singular version, just selects the line.

\n\r can be used to find a blank line.

--

Alex.







Re: Selecting all text between blank lines

John Shotsky
 

I agree with this, except I do it this way:
\R\R+
In case there are more than one blank line present. In my work, that often
happens.
The reason \R is best is that there are different ways a line end is handled by
different operating system - windows, Unix and Apple are all different. \R works
for all of them.
In fact, when I first open any new doc, the first thing I do is replace \R with
\r\n, so I KNOW I have the Windows CRLF throughout.

Regards,
John

-----Original Message-----
From: Clips@Notetab.groups.io <Clips@Notetab.groups.io> On Behalf Of Axel Berger
Sent: Sunday, January 23, 2022 4:15 PM
To: Clips@Notetab.groups.io
Subject: Re: [NTB-Clps] Selecting all text between blank lines

Alex Plantema wrote:
\n\r can be used to find a blank line.
Better \R and for a blank line you need \R\R.


--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
 X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --


Re: Selecting all text between blank lines

Axel Berger
 

Alex Plantema wrote:
\n\r can be used to find a blank line.
Better \R and for a blank line you need \R\R.


--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
 X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --


Re: Selecting all text between blank lines

Axel Berger
 

Ian Rastall wrote:
It doesn't work with the last record, as there's no last line in
the document.)
Yes, that's a frequent problem. I often begin my clips with appending an
empty or a dummy line. If a dummy, you make delting it your last command.

This is an example where "sig:" is the beginning of the first line of every
block:

^!Jump TEXT_END
^!InsertText sig:
...
:loop
^!Find "(?s)^abs: (.*?)^sig:" HRS1
...
^!Jump TEXT_END
^!DeleteLine


--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
 X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --

1 - 20 of 26352