4.85 regexs - Substring Match

Format 1: regexs($str$,regular expression)

Format 2: regexsw($str$,regular expression)

Return the starting position of the longest substring where the defined regular expression matches with part of the character string $str$. Use the regexsw function if $str$ or regular expression contain multibyte characters, or when characters in Shift_JIS encoding does not correspond to search results.

Example

Example 1: Basic Example

Records that contain the regular expression starting with c until aa includes id=1,id=2. The function returns true for matching records.

$ more dat1.csv
id,str
1,caabaa
2,acabaaa
3,
4,cbcbcc
$ mcal c='regexs($s{str},"c.*aa")' a=rsl i=dat1.csv o=rsl1.csv
#END# kgcal a=rsl c=regexs($s{str},"c.*aa") i=dat1.csv o=rsl1.csv
$ more rsl1.csv
id,str,rsl
1,caabaa,1
2,acabaaa,1
3,,0
4,cbcbcc,0

Example 2: Match start of string

The regular expression .*c which matches the value in the $str$ column for all records except id=3.

$ mcal c='regexs($s{str},".*c")' a=rsl i=dat1.csv o=rsl2.csv
#END# kgcal a=rsl c=regexs($s{str},".*c") i=dat1.csv o=rsl2.csv
$ more rsl2.csv
id,str,rsl
1,caabaa,1
2,acabaaa,1
3,,0
4,cbcbcc,1