Defines or extract a search pattern

Description

Patterns defines how searches are conducted against a searchable target

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
pattern(object, type, ...)

## Default S3 method:
pattern(object = NULL, type = "std", ...)

## S3 method for class 'character'
pattern(object, type = "std", ...)

## S3 method for class 'Pattern'
pattern(object, type = object@type, ...)

## S3 method for class 'Searchable'
pattern(object, type = object@type, ...)

## S4 method for signature 'Pattern'
show(object)

Arguments

object

character or pattern;

type

character; the type of match: std (default), regex, coll, fixed.

...

additional arguments to be passed to stri_opts_* functions. See details.

The pattern class defines how the search is conducted.

The function pattern is the constructor for the class. It takes a 'string' can be used to define a pattern that controls matching against a searchable target. Most often the user will want to use the type specific functions: regex, coll, fixed or basic. Eacb is described below.

These are closely related to the

Slots

.Data

character object representing a pattern.

type

character; type of search performed; one of "std" (default), "regex", "fixed", "coll", or "charclass". See details.

options

list; name = value pairs for search options used.

std

The default is std matching which performs matching as base R would. This is equivalent to fixed and case_insensitive = FALSE. Though the internal matching is sed.

regex

regex matching takes a regular expression for matching using

stri_*_regex functions.

coll

...

fixed

...

Examples

1
2
pattern('hello')
  pattern('hello', type="regex", boundary="starts_with" )