Package 'rebus.numbers'

Title: Numeric Extensions for the 'rebus' Package
Description: Build regular expressions piece by piece using human readable code. This package contains number-related functionality, and is primarily intended to be used by package developers.
Authors: Richard Cotton [aut, cre]
Maintainer: Richard Cotton <[email protected]>
License: Unlimited
Version: 0.0-1
Built: 2024-11-19 05:56:04 UTC
Source: https://github.com/richierocks/rebus.numbers

Help Index


Generate a regular expression for a number range

Description

Generates a regular expression that matches a sequence of numbers.

Usage

number_range(lo, hi, allow_leading_zeroes = FALSE, capture = FALSE)

Arguments

lo

An integer.

hi

An integer greater than or equal to lo.

allow_leading_zeroes

A logical value. Are leading zeroes allowed to bulk the match up to the length of the number with the most digits?

capture

A logical value. See or for details.

Value

A character vector representing part or all of a regular expression.

Examples

number_range(0, 255)
number_range(0, 255, allow_leading_zeroes = TRUE)
number_range(10000, 19999)
number_range(6, 54321)
number_range(-77, 77)
number_range(-77, 77, capture = TRUE)
number_range(-77, 77, capture = NA)

Roman numerals

Description

Match roman numerals.

Usage

ROMAN

roman(lo, hi)

Arguments

lo

A non-negative integer. Minimum number of repeats, when grouped.

hi

positive integer. Maximum number of repeats, when grouped.

Format

An object of class regex (inherits from character) of length 1.

See Also

as.roman

Examples

# Constant form and character class
ROMAN
roman()

x <- c("MMMDCCCXLVIII", "MMMCMDCCCXLVIIV")
rx <- rebus.base::exactly(roman())
grepl(rx, x)