I’m having issues with a regular expression. I have a file that looked in the same directory for a xml file and would see if it had a .xml extension and if it didn’t it would append it. So I had a regexp like:
XML_FileName = 'RandomFile.xml';stringPresent = strfind(XML_FileName, '.');if ~isempty(stringPresent) stringParts = regexp(XML_FileName, '.', 'split'); if ~isequal(stringParts{end}, 'xml') error('Not and XML file'); end end
But I had someone try this:
XML_FileName = '..\NewFolder\RandomFile.xml';
And this didn’t work. I can’t figure out the regular expression to get this working. I tried:
stringParts = regexp(idfFileName, '[*\.*\\\w+\d+]\.[*\w]', 'split')
which I thought was, look for zero or more . and \ with one or more characters and number with a . and a few characters at the end. This didn’t work and variations of this didn’t work. I would like this to work if someone enters just the file name or a path location. Thanks!
Best Answer