new warning in 1.8 from String#split

P

Phil Tomson

I've got a little email filtering program that I've been using for a while
that has the line:

msg.header.split("\r\n").grep(/^From: /)

When I tried to run this script on Ruby 1.8 I got:

"warning: string pattern instead of regexp; metacharacters no longer
effective"

A bit of irb'ing and I determined that the problem is the split("\r\n")
and it'll apparently work fine if I change the string to a regex.

So does this basically mean that if we're using escaped characters in the
split that we can no longer use strings and we must use regexen?

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top