Stata 15 help for mf_ustrregex

Title

[M-5] ustrregexm() -- Unicode regular expression match

Syntax

real matrix ustrregexm(string matrix s, string matrix re [, real scalar noc])

string matrix ustrregexrf(string matrix s1, string matrix re, string matrix s2 [, real scalar noc])

string matrix ustrregexra(string matrix s1, string matrix re, string matrix s2 [, real scalar noc])

string matrix ustrregexs(real matrix r)

Description

ustrregexm(s, re [, noc]) performs a match of a regular expression and evaluates to 1 if regular expression re is satisfied by the Unicode string s; otherwise, it evaluates to 0. If noc is specified and is not zero, a case insensitive match is performed.

ustrregexrf(s1, re, s2 [, noc]) replaces the first substring within the Unicode string s1 that matches re with s2 and returns the resulting string. If noc is specified and is not zero, a case insensitive match is performed.

ustrregexra(s1, re, s2 [, noc]) replaces all substrings within the Unicode string s1 that match re with s2 and returns the resulting string. If noc is specified and is not zero, a case insensitive match is performed.

ustrregexs(r) returns subexpression r from a previous ustrregexm() match. Subexpression 0 is reserved for the entire string that satisfied the regular expression. The function may return an empty string if r is larger than the maximum count of subexpressions from the previous match.

When s, s1, s2, re, and r are not scalar, these functions return element-by-element results.

Remarks

An invalid UTF-8 sequence is replaced with the Unicode replacement character \ufffd before the match is performed.

Conformability

ustrregexm(s, re [, noc]), ustrregexrf(s1, re, s2 [, noc]), ustrregexra(s1, re, s2 [, noc]): s: r x c s1: r x c or 1 x 1 re: r x c or 1 x 1 s2: r x c or 1 x 1 noc: 1 x 1 result: r x c

ustrregexrs(r): r: 1 x 1 result: 1 x 1

Diagnostics

ustrregexm() returns a negative integer if an error occurs.

ustrregexrf(), ustrregexra(), and ustrregexrs() return an empty string if an error occurs.

Source code

Functions are built in.


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index