|
-
Jun 23rd, 2005, 08:05 AM
#1
[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(...
Last edited by NoteMe; Jun 23rd, 2005 at 08:44 AM.
-
Jun 23rd, 2005, 08:39 AM
#2
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
-
Jun 23rd, 2005, 08:44 AM
#3
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|