The character class \S matches a single character so it can't match the full
string. The expression ($img =~ /\S/) will only return "true" or "false"
because you don't use the /g global option and/or you don't have any capturing
parentheses in the pattern.

> - why doesn't the second (extracting) match work.

Because the pattern /^(\d)-(\d+)-(\w)$/ doesn't match the string
'0-52557-wind'. -(\w)$ will only match one character between a hyphen and
the end of the line but your string has four characters (wind) between the
hyphen and the end of the line.

John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!