![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
Regex help
Hi all,
I need some help with a regular expression. I need to match entire Python functions; so, beginning with "(\W+)def .*(.*):" I need to math the following line, assuming it begins with more whitespace the first line, and any following lines that begin with the same amount of whitespace as that line. I am not worried about one-liners and other details right now, just what I described. Please help! I'm not even sure this is possible, but I hope it is. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
Re: Regex help
Try something like:
r"^\W*def .*\(.*\):.*\n(\W+).*(\n\1.*)*" Notes:
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| RegEx problem.. | cyphix | PHP | 4 | Mar 4th, 2007 6:24 AM |
| Email validating regex | Jimbo | PHP | 6 | Jul 6th, 2006 2:58 PM |
| regex (preg_replace) parsing | para | PHP | 2 | Dec 31st, 2005 6:30 PM |
| Regex help | Simon Gray | PHP | 10 | Sep 7th, 2005 11:02 AM |
| Need quick help with regex | EyeLezz | C# | 0 | May 16th, 2005 7:42 PM |