Have to try

Gerson Kurz gerson.kurz at t-online.de
Sun Feb 17 01:08:42 EST 2002


>OK - I know I am going to get fried here but - I am out of options. I'm a
>programmer (Java, VB and C++) ...
> I want to search that string for the occurrence of a substring

If you know C, perhaps you'll find these functions usefull:

def strcmp(a,b):
    "Compare two strings, case-sensitive"
    return a == b

def stricmp(a,b):
    "Compare two strings, not case-sensitive"
    return a.lower() == b.lower()

def strncmp(a,b):
    "Compare the first len(b) characters of a and b, case-sensitive"
    return a[:len(b)] == b

def strnicmp(a,b):
    """Compare the first len(b) characters
    of a and b, not case-sensitive"""
    return a[:len(b)].lower() == b.lower()

def strstr(a,b):
    "Return part of a that starts with substring b"
    x = a.find(b)
    if x >= 0: return a[x:]




More information about the Python-list mailing list