Nika-Soft logo Nika-Soft logo

PBRegexp

Function of_getmatch

Description

Returns the captured string for a specified group.

Syntax

instancename.of_getmatch ( text {, group } )
ArgumentDescription
instancenameInstance name of n_cst_re
textString from which the cuptured substring will be extracted
group (optional)Integer specifying the number of cuptured group. The default is 0.

Return value

String. Returns the captured string for a specified group.

Examples

n_cst_re lnvo_re
string   ls_text
string   ls_day, ls_month, ls_year, ls_date

ls_text = ' date of payment: 01.11.2004  '
lnvo_re = create n_cst_re

if lnvo_re.of_exec(ls_text, &
       '/    #whole date cuptured in group 0           ~r~n&
             (\d{1,2})     #day cuptured in group 1    ~r~n&
          \. (\d{1,2})     #month cuptured in group 2  ~r~n&
          \. (\d{4}|\d{2}) #year cuptured in group 3   ~r~n&
        /x') = 1 then
   ls_date   = lnvo_re.of_getmatch(ls_text)     //'01.11.2004'
   ls_day    = lnvo_re.of_getmatch(ls_text, 1)  //'01'
   ls_month  = lnvo_re.of_getmatch(ls_text, 2)  //'11'
   ls_year   = lnvo_re.of_getmatch(ls_text, 3)  //'2004'
end if
Copyright © NikaSoft 2004-2005