[Changeset] Re: Behavior of the matlab regexptranslate function

David Bateman adb014 at gmail.com
Sun Mar 23 17:22:34 CDT 2008


Ben Abbott wrote:
> I just finished the install of 2008a. The results from 2008a and 2007b
> (the same) are below.
> 
>>> regexp ('file1.mat file2.mat file3.xls file4.mat', ...
> regexptranslate('wildcard','*.mat'), 'match')
> 
> ans =
> 
>     'file1.mat file2.mat file3.xls file4.mat'
> 
>>> regexptranslate('wildcard','*.mat')
> 
> ans =
> 
> .*\.mat
> 
> Ben


Tine to file a bug report against matlab then.. In any case thinking
further about it replacing '*.mat' with '.*\.mat' makes as much sense as
replacing it with '\w+\.mat' as otherwise how do you treat filenames
with spaces in them.. I suspect this is a case of a matlab developer
trying the write the DoWhatIWantNotWhatIAsked function, and the moral is
that you should learn the syntax of regexp rather than relying on a
particular behavior of the regexptranslate function.

In any case I attach a changeset that duplicates the behavior of the
matlab function.

D.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch7795
Url: https://www.cae.wisc.edu/pipermail/octave-maintainers/attachments/20080323/bb456890/attachment-0001.ksh 


More information about the Octave-maintainers mailing list