
May 15th, 2004, 12:57 PM
|
|
Contributing User
|
|
Join Date: Feb 2004
Location: London, England
|
|
|
If I understand correctly, you want to match on two 'words' of non-whitespace characters, separated by a single space, whose total length is <= 25 characters (including the space).
This is doable in a single regular expression, but not easily. You could do something like:
regex= r'(\S \S{1,23})|(\S{2} \S{1,22})|(\S{3} \S{1,21})|...|(\S{23} \S)'
Where '...' in the above needs to be filled with all the intermediate combinations.
but this would be very cumbersome and probably highly inefficient.
I think it would be better to match on r'\S+ \S+' and then filter out the matches that are too long.
Dave - The Developers' Coach
|