In a future PCRE enhancement, it could be possible to retrieve a "mark string" after a match operation. The pattern would contain constructs that would cause the info to be written to a pointed place stated in the pcre_extra block (if a proper one is available). The string communicates "how" a pattern matched.
Status is, there is currently a test version of pcre available with the feature in it, and the developer requests feedback. For example, the pattern X(*MARK:A)Y|X(*MARK:B)Z after matching against XY, the markstring would be "A". Other verbs could also set the string. E.g., (*PRUNE:A) would be equivalent to (*MARK:A)(*PRUNE). (*THEN:A) would be the same as (*MARK:A)(*THEN). I guess the point is, after the match, it could be possible to do some conditional processing dependent on the content of the markstring. I suppose some new regex plugin option might be needed to communicate that when you want a markstring. ? Appears the pcretest.exe app in the test version has an option to retrieve the markstring. >From the draft pcreapi doc: If PCRE_EXTRA_MARK is set in the flags field, the mark field must be set to point to a char * variable. If the pattern contains any backtracking control verbs such as (*MARK:NAME), and the execution ends up with a name to pass back, a pointer to the name string (zero terminated) is placed in the variable pointed to by the mark field. The names are within the compiled pattern; if you wish to retain such a name you must copy it before freeing the memory of a compiled pattern. If there is no name to pass back, the variable pointed to by the mark field set to NULL. For details of the backtracking control verbs, see the section entitled "Backtracking control" in the pcrepattern documentation. Regards, Sheri