The regex you gave will match on every $key that consists of:
- the beginning of the string
- immediately followed by the lowercase letter 'r'
- immediately followed by one or more digits,
which are stored in $1
- immediately followed by the lowercase letter 'c'
- immediately followed by one or more digits,
which are stored in $2
- immediately followed by the end og the string.
The () will capture the enclosed expression and put it into
the variable $n, with n being the number of the opening '('.
| $key=~/^r(\d+)c(\d+)$/
||\___/|\___/|
|| | | | `---- end of string
|| | | `------- one or more digits => $2
|| | `---------- the letter 'c'
|| `------------- one or more digits => $1
|`---------------- the letter 'r'
`----------------- beginning of string
Matching $key's would be 'r123c47' or 'r0c99999'.
Hope this helps,
-- Marcus
| -----Original Message-----
| From: Jerry Preston [mailto:[EMAIL PROTECTED]]
| Sent: Tuesday, January 15, 2002 1:14 PM
| To: begginners
| Subject: need help to understand a regex
|
|
| All,
|
| I need to understand this regex in detail:
|
| $key=~/^r(\d+)c(\d+)$/
|
| Thanks for your help and time,
|
| Jerry
|
|
| --
| To unsubscribe, e-mail: [EMAIL PROTECTED]
| For additional commands, e-mail: [EMAIL PROTECTED]
|
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]