findobj -regexp documentation error?

  • Follow


The doc information
'Accessing Object Handles :: Handle Graphics Objects (Graphics)'
has the section,

  Limiting the Search with Regular Expressions.
    Increase the value of the MarkerSize property by 2 points on
    all stemseries objects that do not have their property Tag set to
    'Steady State'.

    h = findobj('-regexp','Tag','[^Steady State]');
    set(h,{'MarkerSize'},num2cell(cell2mat(get(h,'MarkerSize'))+2))

Wouldn't this match tags whose letter are all not any of
'a', 'd', 'e', 't', 'y', or 'S' ?

That is, isn't the regexp '[^Steady State]' the syntax for
a negated character class, rather than the syntax for "anything
except the following string" ?

For example, if one sets the tag to 'taSty yeaSt', findobj with
the above expression will not find it.
-- 
  "law -- it's a commodity"
                         -- Andrew Ryan (The Globe and Mail, 2005/11/26)
0
Reply roberson2 (8067) 5/15/2007 10:59:22 PM

findobj's regexp has bugs that I reported to TMW back in August 2006
(R2006a). I don't know whether this bug existed prior to R2006a.

Yair Altman
0
Reply altmanyDEL (1123) 5/16/2007 2:55:27 PM


Walter Roberson wrote:
>
>
> The doc information
> 'Accessing Object Handles :: Handle Graphics Objects (Graphics)'
> has the section,
>
> Limiting the Search with Regular Expressions.
> Increase the value of the MarkerSize property by 2 points on
> all stemseries objects that do not have their property Tag set
> to
> 'Steady State'.
>
> h = findobj('-regexp','Tag','[^Steady State]');
> set(h,{'MarkerSize'},num2cell(cell2mat(get(h,'MarkerSize'))+2))
>
> Wouldn't this match tags whose letter are all not any of
> 'a', 'd', 'e', 't', 'y', or 'S' ?
>
> That is, isn't the regexp '[^Steady State]' the syntax for
> a negated character class, rather than the syntax for "anything
> except the following string" ?
>
> For example, if one sets the tag to 'taSty yeaSt', findobj with
> the above expression will not find it.
> --
> "law -- it's a commodity"
> -- Andrew Ryan (The Globe and Mail,
> 2005/11/26)
>
  
You are right. However, in which version did you find this? I cannot
find it in R2006b or R2007a.

It is a very poor example, but I guess it will work in nine out of
ten cases.

/ per
0
Reply poi1 (291) 5/16/2007 5:24:32 PM

In article <ef57043.1@webcrossing.raydaftYaTP>,
per isakson <poi1@kth2.se> wrote:
>Walter Roberson wrote:

>> The doc information
>> 'Accessing Object Handles :: Handle Graphics Objects (Graphics)'
>> has the section,

>> Limiting the Search with Regular Expressions.

>> h = findobj('-regexp','Tag','[^Steady State]');

>You are right. However, in which version did you find this? I cannot
>find it in R2006b or R2007a.

R2007a.

Search the Index for  limiting the search
The first result, 'Accessing Object Handles' has the example
slightly more than half-way down.
-- 
  If you lie to the compiler, it will get its revenge. -- Henry Spencer
0
Reply roberson2 (8067) 5/16/2007 5:41:30 PM

That is a bug in the findobj documentation, and its behavior is exactly
as you describe it.

To use findobj -regexp to not match a specified string, use the pattern:

h = findobj('-regexp', 'Tag', '^(?!Steady State$).');

Good luck.

-=>J
0
Reply tendiamonds (54) 5/16/2007 5:53:16 PM

4 Replies
55 Views

(page loaded in 0.099 seconds)


Reply: