Software >> Programming >> Perl >> regexp >> How to use backreference

e.g. To match the following string
Total length: 10
1st character: lowercase letter.
2nd character: word character.
3rd character: whitespace character.
4th character: non word character.
5th character: digit.
6th character: should be same as 1st character.
7th character: should be same as 2nd character.
8th character: should be same as 3rd character.
9th character: should be same as 4th character.
10th character: should be same as 5th character.

$Regex_Pattern = '^([a-z])(\w)(\s)(\W)(\d)$';