regexoption

Specifies the syntax, character encoding and option of regular expression.

regexoption <option1> [<option2> ...]

Remarks

This command specifies the the syntax, character encoding and option of regular expression regarding the strmatch, strreplace and waitregex.

The option1 [option2 ...] can specify one of below syntaxes or encodings, some options.
These default value are the Syntax:SYNTAX_RUBY, the Encoding: ENCODING_ASCII and the Option: OPTION_NONE.

Type Option Name (short form) Description
Syntax SYNTAX_DEFAULT - Default (Ruby style)
SYNTAX_ASIS ASIS plain text
SYNTAX_POSIX_BASIC POSIX_BASIC POSIX Basic RE
SYNTAX_POSIX_EXTENDED POSIX_EXTENDED POSIX Extended RE
SYNTAX_EMACS EMACS Emacs style RE
SYNTAX_GREP GREP grep style RE
SYNTAX_GNU_REGEX GNU_REGEX GNU Regex
SYNTAX_JAVA JAVA Java style
SYNTAX_PERL PERL Perl style
SYNTAX_PERL_NG PERL_NG Perl + named group
SYNTAX_RUBY RUBY Ruby style
Encoding ENCODING_ASCII ASCII ASCII encoding
ENCODING_ISO_8859_1 ISO_8859_1 ISO 8859-1 encoding
ENCODING_ISO_8859_2 ISO_8859_2 ISO 8859-2 encoding
ENCODING_ISO_8859_3 ISO_8859_3 ISO 8859-3 encoding
ENCODING_ISO_8859_4 ISO_8859_4 ISO 8859-4 encoding
ENCODING_ISO_8859_5 ISO_8859_5 ISO 8859-5 encoding
ENCODING_ISO_8859_6 ISO_8859_6 ISO 8859-6 encoding
ENCODING_ISO_8859_7 ISO_8859_7 ISO 8859-7 encoding
ENCODING_ISO_8859_8 ISO_8859_8 ISO 8859-8 encoding
ENCODING_ISO_8859_9 ISO_8859_9 ISO 8859-9 encoding
ENCODING_ISO_8859_10 ISO_8859_10 ISO 8859-10 encoding
ENCODING_ISO_8859_11 ISO_8859_11 ISO 8859-11 encoding
ENCODING_ISO_8859_13 ISO_8859_13 ISO 8859-13 encoding
ENCODING_ISO_8859_14 ISO_8859_14 ISO 8859-14 encoding
ENCODING_ISO_8859_15 ISO_8859_15 ISO 8859-15 encoding
ENCODING_ISO_8859_16 ISO_8859_16 ISO 8859-16 encoding
ENCODING_UTF8 UTF8 UTF-8 encoding
ENCODING_UTF16_BE UTF16_BE UTF-16 (Big Endian) encoding
ENCODING_UTF16_LE UTF16_LE UTF-16 (Little Endian) encoding
ENCODING_UTF32_BE UTF32_BE UTF-32 (Big Endian) encoding
ENCODING_UTF32_LE UTF32_LE UTF-32 (Little Endian) encoding
ENCODING_EUC_JP EUC_JP EUC-JP encoding
ENCODING_EUC_TW EUC_TW EUC-TW encoding
ENCODING_EUC_KR EUC_KR EUC-KR encoding
ENCODING_EUC_CN EUC_CN EUC-CN encoding
ENCODING_SJIS SJIS Shift_JIS encoding
ENCODING_KOI8_R KOI8_R KOI8-R encoding
ENCODING_CP1251 CP1251 CP1251 encoding
ENCODING_BIG5 BIG5 Big5 encoding
ENCODING_GB18030 GB18030 GB18030 encoding
Option OPTION_NONE - no option
OPTION_SINGLELINE SINGLELINE '^' -> '\A', '$' -> '\Z'
OPTION_MULTILINE MULTILINE '.' match with newline
OPTION_IGNORECASE IGNORECASE ambiguity match on
OPTION_EXTEND EXTEND extended pattern form
OPTION_FIND_LONGEST FIND_LONGEST find longest match
OPTION_FIND_NOT_EMPTY FIND_NOT_EMPTY ignore empty match
OPTION_NEGATE_SINGLELINE NEGATE_SINGLELINE clear ONIG_OPTION_SINGLELIN
OPTION_DONT_CAPTURE_GROUP DONT_CAPTURE_GROUP only named group captured
OPTION_CAPTURE_GROUP CAPTURE_GROUP named and no-named group captured

Example

string="test  string"
pattern=""

regexoption "IGNORECASE"
strmatch string pattern
messagebox result "ASCII"        ; result -> 0 (Not Match)

regexoption "ISO_8859_1" "IGNORECASE"
strmatch string pattern
messagebox result "ISO_8859_1"   ; result -> 6 (Match)
string="Test (PaTTerN) String"
pattern="(pattern)"

regexoption "IGNORECASE"
strmatch string pattern
sprintf2 msg 'result=%d, matchstr="%s"' result matchstr
messagebox msg "IGNORECASE"          ; result=7, matchstr="PaTTerN"

regexoption "ASIS" "IGNORECASE"
strmatch string pattern
sprintf2 msg 'result=%d, matchstr="%s"' result matchstr
messagebox msg "IGNORECASE + ASIS"   ; result=6, matchstr="(PaTTerN)"

See also