Hi, sitting here reading for my exam and found this in last years exam:
A project has generated a numbered sequence of xml files. The filenames of interest consist of a 3 digit zero-padded number followed by ".xml" extension. Which regular expression will match all these numbered xml files, but NOT files that have letters before the .xml, have a sequence number with more than 3 digits, or have a ~ appended to the end?
a) "...\.xml$"
b) "[0-9]*3\.xml$"
c) "[0-9]\{3\}\.xml"
d) "[0-9]*\.xml$"
The problem is that I can't find any of the options to fit into the specification...
as I see it:
a) will match e.g. a99.xml
b) will not match every correct filename because of having the "hardcoded" number 3 in it
c) will match even if a ~ is appended
d) will match 000000222.xml
and on top of this; all the options will match if there is a leading letter etc. because the ^ is missing in the beginning of the regexp.
anyone out there that can find one that will match or is it not possible to answer correct on this question?
btw my lecturer isn't available, therefore I ask you guys
eremit