Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python

Name: Anonymous 2013-03-20 2:39

Hey /prog/

Is there a way to ignore casing when searching for a substring in a string in python?

Name: Anonymous 2013-03-20 2:42

is there a way
tolower() or its equivalent, if nothing else.
is there a better way
Probably, but I don't know Python.  Read the API docs.

Name: Anonymous 2013-03-20 2:46

>>2
What I'm doing needs to return the original string I'm looking for in its original format. Not all lowercase, otherwise this would be easy.

Name: Anonymous 2013-03-20 3:03

>>3

You could save the indices.

Or you could read the standard library documentation.

Name: Anonymous 2013-03-20 3:10

Use tolower(), as str.find returns a position in the string.
So you can use str.find on the lowercased string, and then return what it really is using the original string.

Name: Anonymous 2013-03-20 3:48

Alright, I got it! Thanks /prog/

However, another question: How about ignoring punctuation without importing string and using string.punctuation()?

Name: Anonymous 2013-03-20 3:51

FIOC IS EVIL

Name: Anonymous 2013-03-20 4:25

Okay.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List