Mark Thomas
5/14/2009 11:47:00 AM
On May 14, 7:01 am, Mikael Björkegren <mb.s...@live.se> wrote:
> Hello!
>
> Anyone who can help me with this. If i have a string and want to take
> out a sub string of that by regexp.
>
> 1. string = "Today is it monday after work. blah blah."
> or
> 2. string2 = "monday morning. Nice day today."
>
> And i would like to get a certain line with the word monday in it.
> Like results below.
>
> 1. result = "Today is it monday after work"
> 2. result2 = "monday morning"
So you want the sentence, not including the period? What if there is a
preceding sentence?
Try
puts string[/[^.]*[Mm]onday[^.]*/]
-- Mark.