Wolfram Computation Meets Knowledge

Wolfram Language & System Documentation Center Wolfram Language Home Page »

RegularExpression

RegularExpression["regex"]

represents the generalized regular expression specified by the string "regex".

Details

Examples

open allclose all

Basic Examples  (2)

Find words involving the characters a, b, c, d, e:

Equivalent form using string patterns:

Decide whether the string consists of words and whitespace:

Equivalent form using string patterns:

Scope  (21)

Basic Constructs  (17)

Extract any character except newline:

Either of the characters "a" and "b":

Any character between "a" and "e", including "a" and "e":

Any character except "a" and "1":

Any digit repeated one or more times:

The character "a" repeated 2 or 3 times:

Any digit:

Nondigit characters:

Space, newline, tab, or other whitespace character:

Non-whitespace characters:

Word characters:

Nonword characters:

Find all uppercase letters:

Split a string at the beginning of a new line:

Split a string at the end of a new line:

Insert a character at the boundary of each word:

Split a string at every character except at the boundary of a word:

Compound Constructs  (4)

StringExpression can contain RegularExpression objects:

Conditional patterns:

Use alternatives to match one or more line breaks:

Non-greedy matches are done by appending a question mark "?" to the quantifiers:

Generalizations & Extensions  (1)

The $1 refers to the letter matched by (.):

Numbered subpatterns:

Properties & Relations  (3)

Use StringMatchQ to determine string pattern matches:

Use StringCases to find matching substrings:

Use StringSplit to split a string into substrings using a delimiter pattern:

Wolfram Research (2004), RegularExpression, Wolfram Language function, https://reference.wolfram.com/language/ref/RegularExpression.html.

Text

Wolfram Research (2004), RegularExpression, Wolfram Language function, https://reference.wolfram.com/language/ref/RegularExpression.html.

CMS

Wolfram Language. 2004. "RegularExpression." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RegularExpression.html.

APA

Wolfram Language. (2004). RegularExpression. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RegularExpression.html

BibTeX

@misc{reference.wolfram_2024_regularexpression, author="Wolfram Research", title="{RegularExpression}", year="2004", howpublished="\url{https://reference.wolfram.com/language/ref/RegularExpression.html}", note=[Accessed: 18-May-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_regularexpression, organization={Wolfram Research}, title={RegularExpression}, year={2004}, url={https://reference.wolfram.com/language/ref/RegularExpression.html}, note=[Accessed: 18-May-2024 ]}

Top