Format 1: regexstr(
,regular expression)
Format 2: regexstrw(
,regular expression)
Return the longest substring where the defined regular expression matches part of the character string
. Use the regexstrw function if
or regular expression contain multibyte characters, or when characters in Shift_JIS encoding does not correspond to search results.
Extract the longest substring that matches the regular expression c.*a. At row where id=2, the regular expression matches the string cba and cbaa, however, the longer substring is returned.
$ more dat1.csv
id,str
1,xcbbbayy
2,xxcbaay
3,
4,bacabbca
$ mcal c='regexstr($s{str},"c.*a")' a=rsl i=dat1.csv o=rsl1.csv
#END# kgcal a=rsl c=regexstr($s{str},"c.*a") i=dat1.csv o=rsl1.csv
$ more rsl1.csv
id,str,rsl
1,xcbbbayy,cbbba
2,xxcbaay,cbaa
3,,
4,bacabbca,cabbca