JayX JayX - 1 year ago 70
Ruby Question

How do I remove substring after a certain character in a string using Ruby?

I guess it's an easy question

How do I do this?

Answer Source
new_str = str.slice(0..(str.index('blah')))

alt text

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download