Reply to topic  [ 3 posts ] 
Need some help I don't quite get all this dot stuff 
Author Message
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
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


2010-07-18 00:53:41
Profile WWW

Joined: 2008-05-17 04:02:32
Posts: 400
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.


2010-07-18 01:44:57
Profile
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
Kino,

Amazing. Thank you again for all your help.

best
Lou


2010-07-19 17:20:35
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software