Learn R Programming

ore (version 1.0.6)

ore: Oniguruma regular expressions

Description

Create, test for, and print objects of class "ore", which represent Oniguruma regular expressions. These are length-1 character vectors with additional attributes, including a pointer to the compiled version.

Usage

ore(pattern, options = "", encoding = "auto")

is.ore(x)

## S3 method for class 'ore': print(x, ...)

Arguments

pattern
A single string containing a valid regular expression. Note that backslashes should be doubled, to avoid them being interpreted as character escapes by R.
options
A string composed of characters indicating variations on the usual interpretation of the regex. These may currently include "i" for case-insensitive matching, and "m" for multiline matching (in which case "." matches
encoding
The encoding that matching will take place in, a string string naming one of the encoding types discussed in Encoding, or "auto". In the latter case, the encoding of pattern will
x
An R object.
...
Ignored.

Value

  • The ore function returns (the first element of) pattern, with class "ore" and the following attributes:
  • .compiledA low-level pointer to the compiled version of the regular expresion.
  • optionsOptions, copied from the argument of the same name.
  • encodingThe specified or detected encoding.
  • The is.ore function returns a logical vector indicating whether its argument represents an "ore" object.

See Also

For full details of supported syntax, please see https://raw.githubusercontent.com/k-takata/Onigmo/master/doc/RE. The regex page is also useful as a quick reference, since PCRE (used by base R) and Oniguruma (used by ore) have similar features.

Examples

Run this code
# This matches a positive or negative integer
ore("-?\\d+")

# This matches words of exactly four characters
ore("\\b\\w{4}\\b")

Run the code above in your browser using DataLab