String spliting

data = "<input type=\"password\" value=\"hoax\">"

spl = data.split("\"password\"")

The first example works exactly like it should, but when i'm loading the
same line from file it doesn't, even though they are both strings.

Here is the second example

fp = File.open('file','r').read

spl = data.split(/\\"password\"")

How come i can't use the first approach? Is there really difference
between string and a string?

···

--
Posted via http://www.ruby-forum.com/.

\\ -> \

···

On Sep 26, 2013, at 7:04, Michael James <lists@ruby-forum.com> wrote:

spl = data.split(/\\"password\"")

and add / to mark the end of the RegEx

···

On Thu, Sep 26, 2013 at 2:05 PM, Ryan Davis <ryand-ruby@zenspider.com>wrote:

On Sep 26, 2013, at 7:04, Michael James <lists@ruby-forum.com> wrote:

> spl = data.split(/\\"password\"")

\\ -> \

PS: dont use
File.open('file','r').read

because it holds the FilePointer Open, use

File.read('file')

···

--
Posted via http://www.ruby-forum.com/.