[RegEx] finding a word BEFORE a (
How do I do that...like if I have this:
Code:
#Hello mother
def main():
if len(sys.argv) < 1:
usage() #Yeah thats your mother all right
else:
kek_number_list = tidy_up_file(sys.argv[1])
if kek_number_list != -1:
download_pdf(kek_number_list)
It should match "main", "len", "usage", "tidy_up_file", and "download_pdf", but NOT the ( after it.
I tried this:
\s[\d\w^\S]*\(
and it matches the word in front AND the ( but I don't want the(...:(
Re: [RegEx] finding a word BEFORE a (
This is why I love forums you always find something interesting that expands your knowlodge
RegEx:
\b\w+(?=\()
I think this will work
(?=) is a look ahead assertion matches whats within the (?=) but does not return it.
Edit
knowlodge???
Now all I need is a typing/spelling forum :rolleyes:
Re: [RegEx] finding a word BEFORE a (
Wooohooo...yeah you solved it....I am not at that chapter yet...so you saved me a whole lot of reading there...since a function name can hold numbers or underscores too I had to do this:
\b[\w\d_]*(?=\()
and then it will totaly work...:) Thanks a bunch.