new warning in 1.8 from String#split

Discussion in 'Ruby' started by Phil Tomson, Oct 11, 2003.

  1. Phil Tomson

    Phil Tomson Guest

    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
    Phil Tomson, Oct 11, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    466
  2. Carlos Ribeiro
    Replies:
    11
    Views:
    695
    Alex Martelli
    Sep 17, 2004
  3. Chris Morris

    regexp warning in String.split?

    Chris Morris, Aug 15, 2003, in forum: Ruby
    Replies:
    1
    Views:
    92
    Brian Candler
    Aug 15, 2003
  4. Sam Kong
    Replies:
    5
    Views:
    237
    Rick DeNatale
    Aug 12, 2006
  5. Stanley Xu
    Replies:
    2
    Views:
    604
    Stanley Xu
    Mar 23, 2011
Loading...

Share This Page