[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Behavior of the matlab regexptranslate function
From: |
David Bateman |
Subject: |
Re: Behavior of the matlab regexptranslate function |
Date: |
Sat, 22 Mar 2008 01:19:35 +0100 |
User-agent: |
Thunderbird 2.0.0.12 (X11/20080306) |
Ben Abbott wrote:
>
> On Mar 21, 2008, at 4:02 PM, David Bateman wrote:
>> Ben Abbott wrote:
>>>
>>> David,
>>>
>>> I have a license, but have not yet installed it.
>>>
>>> Please post the tests, and if no one steps up, I'll install 2008a and
>>> run them.
>>>
>>> Ben
>>>
>>
>> Something like
>>
>> regexptranslate ('wildcard', '*a?b*c?')
>
> ans =
>
> .*a.b.*c.
>
>> regexptranslate ('wildcard','?a*b?c*')
>
> ans =
>
> .a.*b.c.*
>
>> regexptranslate ('wildcard','*a? *c?')
>
> ans =
>
> .*a. .*c.
>
>> regexptranslate ('wildcard', '?a* ?c*')
>
> ans =
>
> .a.* .c.*
>
>> regexptranslate ('escape', '.a/b\c[d]e$f(g)')
>
> ans =
>
> \.a/b\\c\[d\]e\$f\(g\)
>
> I must admit, having just installed 2008a and never looked at what
> regexptranslate is intended to do, those results all look surprising.
>
> Hopefully, they are what you expected?
>
> Ben
>
>
They are the documented behavior. But rather useless as
regexp ('file1.mat file2.mat file3.xls file4.mat',
regexptranslate('wildcard','*.mat'), 'match')
will return
{'file1.mat file2.mat','file4.mat'}
rather than what the user probably wanted
{'file1.mat','file2.mat','file4.mat'}
and it doesn't follow the example in the documentation of
regexptranslate('wildcard','*.mat')
returning '\w+\.mat' which will produce the above. Maybe matlab special
cased the '*.mat' case and similar... What does the above return with
2008a? With 2008a it returns '.*\.mat'
D.