Skip to main content
Module

x/nonstd/mod.ts>VerbalExpression

A library for useful features that aren't currently in the std library.
Latest
class VerbalExpression
extends RegExp
import { VerbalExpression } from "https://deno.land/x/nonstd@v0.2.2/mod.ts";

Define the VerbalExpression class

Constructors

new
VerbalExpression()

Creates an instance of VerbalExpression.

Properties

private
_modifiers: string
private
_prefixes: string
private
_source: string
private
_suffixes: string

Methods

add(value?: string | number): VerbalExpression

Add stuff to the expression and compile the new expression so it's ready to be used.

Add a regex modifier/flag

Shorthand for anyOf(value)

anyOf(value: Inputs | string[] | number[]): VerbalExpression

Match any of the given characters

Any character any number of times

anythingBut(value: Inputs | string[] | number[]): VerbalExpression

Anything but these characters

Starts a capturing group

A shorthand for lineBreak() for html-minded users

Match a single digit

Ends a capturing group

endOfLine(enable?: boolean): VerbalExpression

Control end-of-line matching

Alias for then() to allow for readable syntax when then() is the first method in the chain.

Match a Line break

Add optional values

multiple(
value: string,
lower: number,
upper?: number,
): VerbalExpression

Match the value zero or more times

Ensure that the parameter does not follow

Repeat the previous at least once

Add alternative expressions

range(...ranges: string[]): VerbalExpression

Matching any character within a range of characters Usage: .range( from, to [, from, to ... ] )

Remove modifier

repeatPrevious(...quantity: number[]): VerbalExpression

Repeat the previous item exactly n times or between n and m times

replace(source: string, value: string): string

Shorthand function for the string.replace function to allow for a more logical flow

searchOneLine(enable?: boolean): VerbalExpression

Control the multiline modifier

Any character(s) at least once

somethingBut(value: Inputs | string[] | number[]): VerbalExpression

Any character at least one time except for these characters

startOfLine(enable?: boolean): VerbalExpression

Control start-of-line matching

stopAtFirst(enable?: boolean): VerbalExpression

Default behaviour is with "g" modifier, so we can turn this another way around than other modifiers

Match a tab character

Look for the value passed

toRegExp(): RegExp

Convert to RegExp object

Match a single whitespace

withAnyCase(enable?: boolean): VerbalExpression

Control case-insensitive matching

Match any alphanumeric

Static Methods

sanitize(value: Inputs): string

Escape meta-characters in the parameter and make it safe for adding to the expression