4.87 regexstr - Match Character String

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

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

Return the longest substring where the defined regular expression matches part of the character string $str$. Use the regexstrw 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

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