Forum: Ruby regular expression,

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
41ffd3f2fee19dbac758664759b0cdfc?d=identicon&s=25 Raja G. (arc)
on 2013-11-08 09:30
a='hi how are you_I am fine"

now if write a[/(.*)/_] here it includes "_" symbol also with hi how are
you. I can use delete() function to delete "_" but I would like to
handle using regular expression alone. how would I write for that?

require output is,

'hi how are you'
9627ec27e4fb3a18be02133b4ddaa901?d=identicon&s=25 Joel P. (virtuoso)
on 2013-11-08 09:46
41ffd3f2fee19dbac758664759b0cdfc?d=identicon&s=25 Raja G. (arc)
on 2013-11-08 09:48
hi,

oh I have made a small mistake, I have tried like a[/(.*)_/, \1]. Thank
you.
13d0171c6ee97074d61f182a6e3a9f4e?d=identicon&s=25 Robert K. (robert_k78)
on 2013-11-08 14:14
(Received via mailing list)
irb(main):001:0> 'hi how are you_I am fine'.sub! /_.*/, ''
=> "hi how are you"

Kind regards

robert
41ffd3f2fee19dbac758664759b0cdfc?d=identicon&s=25 Raja G. (arc)
on 2013-11-08 14:16
hi Robert Klemme

Another clever way, thank you.
This topic is locked and can not be replied to.