[pcre-dev] Extracting non existant pattern name gives 0 leng…

Kezdőlap
Üzenet törlése
Szerző: Jayaprakasam, Kannan
Dátum:  
Címzett: pcre-dev@exim.org
Tárgy: [pcre-dev] Extracting non existant pattern name gives 0 length instead of PCRE_ERROR_NOSUBSTRING
I came up with a pattern that can match a call syntax for function for example
call SqlTxConstantParametersTesting(1.0, ?intparamout?, 1.111, ?decimalparamout?, 'hello', ?strparamout?)
It can optionall have a return value
(?ret?)= call SqlTxConstantParametersTesting(1.0, ?intparamout?, 1.111, ?decimalparamout?, 'hello', ?strparamout?)
The parantheses around the return value are optional.

The regex is


((\\()?\\?(?<retPort>\\w+)\\?\\s*(?(1)\\))=)?
                                                      // Call syntax with stored procedure name
                                                      \\s*(call|exec|execute)\\s+(?<spName>\\w+)(
                                                      // params can be an empty pair of paranthesis or have parameters inside them as well.
                                                      \\(\\s*(?<params>[?\\w\\d\\.',\\s]+)?\\s*\\)
                                                      // paramList along with its paranthesis is optional below so a SP call can be just "exec sp_name" for a stored proc call without any parameters.
                                                      )?




When I match a subject that doesn't contain the return value, and I call
pcre_get_named_substring(m_regexSPCall, sqlStmtUtf8, ovector, matchedCount, "retPort");
lt doesn't return PCRE_ERROR_NOSUBSTRING but 0. Why does this happen?


Thanks,
Kannan