Skip to contents

The functions scan_re() and scan_re2() can be used to scan a regular expression from the console.

Usage

scan_re(perl = TRUE, ...)

scan_re2(perl = TRUE, ...)

Arguments

perl

Logical. If TRUE, the regular expression being scanned is assumed to use PCRE (Perl Compatible Regular Expressions) notation. If FALSE, it is assumed to use base R's default regular expression notation (see base::regex). Contrary to base R's regular expression functions, the default is TRUE.

...

Additional arguments.

Value

An object of class re.

Details

After the function call, R will continue scanning your input until it encounters an empty input line, i.e. until it encounters two consecutive newline symbols (or until it encounters a line with nothing but whitespace characters). In other words, press ENTER twice in a row if you want to stop inputting characters. The function will then return your input as a character vector of length one.

These functions are designed to allow you to input complex text, in particular regular expressions, without dealing with the restrictions of string literals, such as having to use \\ for \.

See also