in reply to Regex: get first N characters but break at whitespace
This saves what is captured in the first set of parentheses into $text, and the match is the first 200 characters until it hits some whitespace followed by what looks like a word. I'm sure you could probably use some of perl's extended regexp capabilities, but that seems to do the job.($text) = $var =~ /^(.{200})(?:\s+\w*)?/s; print $text.$/;
broquaint
Update: apparently you can ;o)
|
|---|