Behavior of the matlab regexptranslate function

David Bateman David.Bateman at motorola.com
Fri Mar 21 11:25:48 CDT 2008


I just looked at the regexptranslate function, as it seems this function
might be useful. In matlab2007b and the documentation of matlab2008a
there is an incoherence in the real and documented behavior of this
function.. Read the documentation and looking at It seems that
regexptranslate ("wildcard", s) might be trivally written as

regexprep(regexprep(regexprep (s,"\\.","\\."),"\\*",".*"),"\\?",".")

and that is exactly how it works in matlab2007b. However the example for
2008a at

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/regexptranslate.html

has the example

files = ['test1.mat, myfile.mat, newfile.txt, ' ...
'jan30.mat, table3.xls'];
regexp(files, regexptranslate('wildcard', '*.mat'), 'match')
ans =
'test1.mat' 'myfile.mat' 'jan30.mat'

and its states that

regexptranslate('wildcard','*.mat')
ans =
\w+\.mat

So what do the "?" and "*" characters really become in matlab2008a after
the use of regexptranslate? Can someone with a copy on 2008a run a
couple of tests for me? In any case there is a large discrepancy between
the matlab documented and real behavior of this function.

D.

-- 
David Bateman                                David.Bateman at motorola.com
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



More information about the Octave-maintainers mailing list