grapes-m-grapes: Perl style infix match function

Description Usage Arguments Examples

Description

This function allows the match syntax to mimic perl's very closely. As in perl the first character is used as a delimiter to separate the regular expression and options. Paired delimiters are supported as in perl, so both '/this/' and 'this' are both supported for instance.

Usage

1

Arguments

pattern

a character delimited regular expression pattern like those in perl

data

character vector to match against

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
string = c('this is a Test', 'string')
string %m% '/test/i'
#paired delimiters
string %m% '{test}i'
#captures return numbered results
string %m% '!(string)!'
#named captures
string %m% '/(?<type>string)/'
# g option also
string %m% '{(\\w+)}g'

jimhester/perlrer documentation built on May 19, 2019, 10:33 a.m.