D
David Frauzel
Quick question.
I have this regexp:
s/(.{$descmin,$descmax} ).*/$1.../
The purpose is to trim a long string by adding '...' at the end of a
truncated version (after the last full word), using $descmin and $descmax
to determine how long the truncated string can be.
This doesn't seem to behave as I thought it ought. Using digits it works
quite nicely:
s/(.{40,50} ).*/$1.../
But introducing the variables seems to confuse the regexp - although I'm
not sure. The documentation (perlre) doesn't seem to address this (or if
I've missed it, please point me to the relevant paragraph!), and my only
other source of "information" is Komodo's Rx Toolkit, which informs me
that it is attempting to match literal '{', literal 'descmin', literal
'descmax', and the dollars are 'end of string'.
Can I not use variables to describe the min and max in a match count
clause?
I have this regexp:
s/(.{$descmin,$descmax} ).*/$1.../
The purpose is to trim a long string by adding '...' at the end of a
truncated version (after the last full word), using $descmin and $descmax
to determine how long the truncated string can be.
This doesn't seem to behave as I thought it ought. Using digits it works
quite nicely:
s/(.{40,50} ).*/$1.../
But introducing the variables seems to confuse the regexp - although I'm
not sure. The documentation (perlre) doesn't seem to address this (or if
I've missed it, please point me to the relevant paragraph!), and my only
other source of "information" is Komodo's Rx Toolkit, which informs me
that it is attempting to match literal '{', literal 'descmin', literal
'descmax', and the dollars are 'end of string'.
Can I not use variables to describe the min and max in a match count
clause?