Regular Expression Options

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

()

Denotes a sub-expression. (abc)+ matches 'abcabcabc'.

i

Makes the regular expression case insensitive. Therefore, /test/i matches positively against strings containing 'TEST', 'TeSt', 'tESt', 'test', or any other combination of lowercase and uppercase letters making up the word "test."

x

Makes the regular expression ignore whitespace. This allows you to format the regular expression in a more readable way without worrying about whitespace becoming part of the regular expression. For example, /t e s t/x matches against "test." This option is particularly useful if you want to spread out your regular expression over multiple lines for easier reading.

[]

Matches a character range or set.

\b

Matches a word boundary (but not a specific character).

\w

Matches any alphanumeric character or underscore.

.

Matches any character except the newline character.

\B

Matches anything \b doesn't match.

\D

Matches anything \d doesn't match (non-digits).

\S

Matches anything \s doesn't match (non-whitespace).

\W

Matches anything \w doesn't match.

\d

Matches digits (0 through 9).

+

Matches one or more of the previous.

+?

Matches one or more, but as few as possible, of the previous.

^

Matches the beginning of a line (or string).

\A

Matches the beginning of a sting.

\Z

Matches the end fo a string.

$

Matches the end of a line (or string).

\s

Matches whitespace characters (spaces, tabs, newlines, form feeds).

*

Matches zero or more of the previous.

*?

Matches zero or more, but as few as possible, of the previous.

?

Matches zero or one of the previous.

m

Puts the regular expression into multiline mode where the special character "." (usually meaning "any character except newline") matches newlines. Therefore, /.*/m matches the whole of a multiline string, whereas /.*/ alone would only match the first line within that string.

|

Separates alternate choices. t|x matches 't' or 'x'.


Kaugnay na mga set ng pag-aaral

Linux Testout Pro 5.0.2 Chp: 1-15

View Set

Auto Insurance: WHAT are the coverage PART D - PHYSICAL DAMAGE

View Set

Chapter 15 Notes: Medical Documents

View Set

Productions and operations Mgmt. Question Exam

View Set

Ch. 6 and 7 AP World History ( The First Global Civilization: The Rise and Spread of Islam and Abbasid Decline)

View Set

Chapter 8: Chemical Equations REVIEW

View Set