Re: Odd behavior of String#scan


#1

From: Dan D. [mailto:removed_email_address@domain.invalid]

Will this do?

s=“abcSTARTdef,ghi,jkl,ENDmno”
s.scan(/START(.*)END/).to_s.split(",")

=> [“def”, “ghi”, “jkl”]

s=“abcSTARTdef,ghi,jkl,ENDmno”
/START(.*)END/.match(s)[1].split(",")

Better conveys the intention to me, but YMMV.

#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################
#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared
by NetIQ MailMarshal
#####################################################################################


#2

Daniel S. wrote:

s=“abcSTARTdef,ghi,jkl,ENDmno”
/START(.*)END/.match(s)[1].split(",")

s[/START(.*?)END/, 1].split(",") # :slight_smile: