/(?:,\s)*(\w+local.xml)/.match('xpl.xml, demoUK.xml, met_local.xml,
cfg.xml')[1]The one I sent before won't work if the filename is the first one in the list. The only difference in this one is the first expression needs the asterisk, but this one worked fine. Don -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Don Conley Sent: Thursday, October 27, 2005 1:24 PM To: [email protected] Subject: Re: [Wtr-general] My regexp is too greedy!! /.*(?:,\s)(\w+local.xml).*/.match('xpl.xml, demoUK.xml, met_local.xml, cfg.xml')[1] That worked for me. Give it a shot. Don -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark Gargan Sent: Thursday, October 27, 2005 12:22 PM To: wtrList (E-mail) Subject: [Wtr-general] My regexp is too greedy!! Have a small problem with the regular expression below. In the line there's a There's a number of files in comma separated list. I'm attempting to extract the name of the file that ends with 'local.xml' i.e. in this case met_local.xml The following ruby expression / (.*local.xml?)/.match('xpl.xml, demoUK.xml, met_local.xml, cfg.xml')[1] returns => "demoUK.xml, met_local.xml" What I need returned is simply "met_local.xml". I was hoping the space at the start of the regexp would mean I'd only get the value " met_local.xml" upon which I could strip the trailing whitespace and leaved me with my file name. I guess it's because the regexp is too greedy. Would anyone have any idea how I could extract just the filename ending in local.xml ? In the last fortnight there's been a serious increase in traffic on this list. Would that be because of the Google mention? Great stuff. Thoroughly deserved. Thanks, Mark. Mark Gargan Software Developer Allfinanz Distribution Software <<http://www.allfinanz.com/>> Direct Line: 213 5115 Fax: +353 1 295 2554 <<mailto:[EMAIL PROTECTED]>> _______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general _______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general _______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
