Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Question Using Regexpi
Date: Wed, 03 Jul 2013 11:15:12 -0500
Organization: Aioe.org NNTP Server
Lines: 69
Message-ID: <kr1ime$b3c$1@speranza.aioe.org>
References: <kr1d2k$3k$1@newscl01ah.mathworks.com> <kr1g6l$3op$1@speranza.aioe.org>
NNTP-Posting-Host: 6z92ouJs6jUrQzBaNtLMgA.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
X-Notice: Filtered by postfilter v. 0.8.2
Xref: news.mathworks.com comp.soft-sys.matlab:798732

On 7/3/2013 10:32 AM, dpb wrote:
...

> I'm no regexp user but '$' doesn't return the last occurrence of a match
> in a strung but the match _followed_immediately_ by the \n sequence.
>
> You need a search from the end to then find the first full word that is
> numeric it would appear. I don't know enough regexp otomh to do it on
> the fly, sorry...but as you've discovered '$' isn't that.

One would think that

regexp(String,'<\\d\>','match')

would find a word containing only digits but it doesn't succeed, 
either... :(

 >> regexp(String,'<\\d\>','match')
ans =
      {}
 >>

OK, is it something about using '\d' inside the <\ ????

 >> regexp(String,'<\[0-9]\>','match')
ans =
      {}
 >>

No, no joy...

OK, are there some other non-printing characters masquerading as 
whitespace or somesuch????

 >> findstr(String,' ')
ans =
      4     8     9    11    12    13    14    17

Nope, blanks on either side so _should_ be a word...

 >> regexp(String,'\d','match')
ans =
     '1'    '6'    '1'
 >> regexp(String,'[ \d ]','match')
ans =
   Columns 1 through 7
     '1'    ' '    ' '    ' '    ' '    ' '    ' '
   Columns 8 through 11
     ' '    '6'    '1'    ' '

And, finds the individual digits surrounded by blanks just to prove it...

OK, let's just parse the form...

 >> String
String =
NR1 MGT  -    61 HOURS
 >> v=sscanf(String(findstr(String,'-')+1:end),'%d')
v =
     61
 >>

Such is why I've always become so frustrated w/ regexp before ever 
actually got anything to work pretty much gave up trying for lack of 
interest in figuring it out enough to understand why what seems that 
should doesn't.  More interesting things to do than pore over regexp 
documentation that seems nearly impenetrable at first blush... :(

--