4.86 regexsfx - Suffix of Matched String

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

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

Return the suffix (substring at the end of character string) of the longest substring where the defined regular expression matches part of the character string $str$. When the same character string and regular expression is used with the three functions to extract different parts of the string in sequential order, namely regexpfx function,regexstr function, and regexsfx function, the original string can be restored by merging the resulting character strings from the functions. Use the regexsfxw 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 suffix of the longest substring that matches the regular expression c.*a. For example, in row where id=4, the regular expression matches cabbca till the ending position in the column, there is no suffix to the matching string, thus NULL character is returned. Since the same input data and substring are used as in the regexstr,regexpfx function, it is easy to compare the results and understand the differences.

$ more dat1.csv
id,str
1,xcbbbayy
2,xxcbaay
3,
4,bacabbca
$ mcal c='regexsfx($s{str},"c.*a")' a=rsl i=dat1.csv o=rsl1.csv
#END# kgcal a=rsl c=regexsfx($s{str},"c.*a") i=dat1.csv o=rsl1.csv
$ more rsl1.csv
id,str,rsl
1,xcbbbayy,yy
2,xxcbaay,y
3,,
4,bacabbca,