[Tutor] Regex

Alan Gauld alan.gauld at yahoo.co.uk
Tue May 4 08:10:32 EDT 2021


On 04/05/2021 12:15, P L wrote:
> I forgot to mention the assignment asks to try to solve via regex 

Ok, I assumed a work assignment not a homework assignment...

>... extract the sentence that follows the word ERROR. 

That's a very different problem from the one you originally presented.
In that case the search is for any one of a number of sentence
terminators - ie any of '.','!','?' (more... in your example string
the 'sentence' does not have a terminator!)

But the regex should still be relatively straightforward if it starts
with ERROR and ends with one of the above terminators. Only the
terminating string changes from 'ticket' to a character group.

But note that the example you posted (ending in 'ticket') does not match
your new description of the problem. 'ticket' is not the end of the
sentence.

Half the problem in developing software is in getting the
specification exactly correct. Once you have that the solution
often effectively writes itself. Can you post a full and specific
description of what you are trying to do?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list