nisus.com
https://www.nisus.com/forum/

Need some help I don't quite get all this dot stuff
https://www.nisus.com/forum/viewtopic.php?f=17&t=3821
Page 1 of 1

Author:  loulesko [ 2010-07-18 00:53:41 ]
Post subject:  Need some help I don't quite get all this dot stuff

I'm trying to extract the chapter number from the text "Chapter 3" which is a previous find from the cursor position. I'm trying to use the following

$sels = $doc.text.find '(?<=Chapter )[[:digit:]](?=\\n)', 'Er-Wr', '-am'

How do I get the number three from $sels it just gives me ranges. I'm not quite hip to this type of coding any help and education appreciated.

thanks
Lou

Author:  Kino [ 2010-07-18 01:44:57 ]
Post subject:  Re: Need some help I don't quite get all this dot stuff

loulesko wrote:
I'm trying to extract the chapter number from the text "Chapter 3" which is a previous find from the cursor position. I'm trying to use the following

$sels = $doc.text.find '(?<=Chapter )[[:digit:]](?=\\n)', 'Er-Wr', '-am'

How do I get the number three from $sels it just gives me ranges.

You can get the number by $n = $sels.subtext or $n = $sels.substring but find command does not know where the cursor is positioned and, with r option, always searches from the end of the document. Try the following instead:
Code:
Find '(?<=Chapter )[[:digit:]]+(?=\n)', 'Er-W', '-am'
$n = Read Selection
Prompt $n
And if you want to verify if the number has been found successfully . . .
Code:
$i = Find '(?<=Chapter )[[:digit:]]+(?=\n)', 'Er-W', '-am'
if $i
   $n = Read Selection
   Prompt $n
else
   Prompt 'Chapter number not found'
end
• I added + (one or more times) after [[:digit:]] because your document may have more than nine chapters.
• You don’t need putting two \ before n although Macroize does.

Author:  loulesko [ 2010-07-19 17:20:35 ]
Post subject:  Re: Need some help I don't quite get all this dot stuff

Kino,

Amazing. Thank you again for all your help.

best
Lou

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/