[Tutor] pattern matching problem

cgw501@york.ac.uk cgw501 at york.ac.uk
Thu May 26 21:46:37 CEST 2005


One of the worst I think was doing loads of real spazzy stuff trying to 
split whole files in to lists of letters and use string methods to find the 
first uppercase one.

The re tutorial has sorted it out for me. I figured this was the way to go, 
I just couldn't work out how to get the index value back...but now I can. 
Thanks!

Chris


On May 26 2005, Danny Yoo wrote:

> 
> 
> On 26 May 2005 cgw501 at york.ac.uk wrote:
> 
> > I have to write a function that will return the index of a line like 
> > this:
> >
> > gvcdgvcgdvagTVTVTVTVTVTHUXHYGSXUHXSU
> >
> > where it first becomes capital letters. I've had about a hundred
> > different ideas of the best way to do this, but always seem to hit a
> > fatal flaw.
> 
> 
> Hi Chris,
> 
> It might be interesting (or amusing) to bring up one of those
> fatally-flawed schemes on the Tutor list, so that we know what not to do.
> *grin*
> 
> In seriousness, your ideas might not be so bad, and one of us here might
> be able to point out a way to correct things and make the approach more
> reasonable.  Show us what you've thought of so far, and that'll help
> catalize the discussion.
> 
> 
> 
> > Any thoughts?
> 
> Have you looked into using a regular expression pattern matcher?  A.M.
> Kuchling has written a tutorial on regular expressions here:
> 
>     http://www.amk.ca/python/howto/regex/
> 
> Would they be applicable to your program?
> 
> 


More information about the Tutor mailing list