Regex frustration

I’m getting stuck on more stupid Ruby stuff this week than I have in
years.

Why can’t I get the regex to recognize a forward slash at the end of a
string?

string = " 77 0 0.150 1.00182 15 1030 1.26/ 8 -0.128"
buffer = string.split( " " )

I can’t match buffer[6] no matter what I try. /// doesn’t work, /\//
doesn’t work. I can match a forward slash somewhere in the string, but
can’t force it to recognize it at the end.

This is getting frustrating because Rubular shows things as working
peachy, then it blows away in my script.

Works for me, what version of Ruby are you using?

[4] pry(main)> buffer[6][///]
=> “/”

Couldn’t really figure out what is the original goal with this, but why
not remove that forward slash during the split phase?

buffer.strip.split(//? +/)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs