Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: RE question: Sentence with a minimum length

by moritz (Cardinal)
on Oct 06, 2008 at 08:52 UTC ( #715530=note: print w/replies, xml ) Need Help??


in reply to RE question: Sentence with a minimum length

You could try something along these lines (untested):
m/\A \s* (\w+\s+\w+?.*?) (??{ length($1) >= 50 }) \s* \z/xs;

(Update: this regex might be very inefficient because both \w+? and .*? might match the same number characters. Use (\w+\s+\w.*?) instead.)

In general that sounds like a problem for which regexes aren't the best solution (split and friends might be better).

Replies are listed 'Best First'.
Re^2: RE question: Sentence with a minimum length
by lima1 (Curate) on Oct 06, 2008 at 08:58 UTC
    Thanks! Yeah, this was also the only way I saw, but I was scared by the experimental warning in perlre. I need a regex here because the API I use requires a regex.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://715530]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2021-04-19 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?