$a = "foo 123 bar"; if ($a =~ m{\d+}xms) { # code that returns 4, the position of 123 } [download]
Originally posted as a Categorized Question.
In reply to How do I retrieve the position of the first occurrence of a match? by lima1