The refer back number are assigned in the order of the opening parenthesis
which starts the definition of the group.

((:(["'])[^\2]*\2)+)
|   |   |          |
|   \---/          |
|     2            |
\------------------/
      1


\1 would refer to that entire expression, and \2 to the inner group. Note
that the unmarked (: and ) are not assigned a referback number because (:
creates a non-capturing group. So \2 captures the leading " or '.   \1
captures the entire string. The (:...) groups stuff together so that I can
put a + after it. This is what allows \1 to extend past the first leading "
( or ') in the case of an embedded, doubled " (or ')  inside the string.

On Mon, Jul 8, 2013 at 6:25 AM, Martin Packer <martin_pac...@uk.ibm.com>
wrote:
> I'm showing my ignorance here - but maybe it's a better class of ignorance
> :-) ...
>
> Why \2 and not \1?  I recognise this as a backreference but don't know
> what happened to the first one.
>
> Cheers, Martin
>
> Martin Packer,
> zChampion, Principal Systems Investigator,
> Worldwide Banking Center of Excellence, IBM
>
> +44-7802-245-584
>
> email: martin_pac...@uk.ibm.com
>
> Twitter / Facebook IDs: MartinPacker
> Blog:
> https://www.ibm.com/developerworks/mydeveloperworks/blogs/MartinPacker
>
>
>
> From:   Elardus Engelbrecht <elardus.engelbre...@sita.co.za>
> To:     IBM-MAIN@listserv.ua.edu,
> Date:   07/08/2013 11:24 AM
> Subject:        Re: Announcing PCRE 8.33 for native z/OS
> Sent by:        IBM Mainframe Discussion List <IBM-MAIN@listserv.ua.edu>
>
>
>
> John McKown wrote:
>
>>I finally got how to parse the string and allow it to start and end with
> either a ' or a ". The start and end character must be the same.
>
>>($x)=$line=~m/((:(["'])[^\2]*\2)+)/;
>
> Thanks! You have cured my curiousity. ;-D
>
> Groete / Greetings
> Elardus Engelbrecht
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>
>
>
>
>
>
>
>
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>
>
>
>
>
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN



-- 
This is a test of the Emergency Broadcast System. If this had been an
actual emergency, do you really think we'd stick around to tell you?

Maranatha! <><
John McKown

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to