Regular expression,

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’


oh I have made a small mistake, I have tried like a[/(.*)_/, \1]. Thank

irb(main):001:0> ‘hi how are you_I am fine’.sub! /_.*/, ‘’
=> “hi how are you”

Kind regards


hi Robert K.

Another clever way, thank you.

You’re almost there:

a[/(.*)_/, 1]