Skip to Main Content

Brown University Scholarly Resources

Regular Expressions


Regular Expressions (regexp) are used for pattern matching in searches. They are best used in finding and replacing features. * Regular Expressions Quick Reference

Commonly Used

Action Format Example Result
Wildcard . a.e Will find "ate", "are", "ale", etc
Match previous element zero or more times * b.*t Will find any characters between b and t, "bent", "beet", "belt", "boot", etc
Match previous element one or more times + be+ Will find "bee", "be", "been", "bent", etc
Match previous element zero or one time ? rai?n Will find "rain", "ran", etc
Match previous element n times {n} \d{3} Will find "043", "999", "877", "001", etc
Match previous element at least n times but not more than m times {n,m} \d{1,3} Will find "0", "04", "975", "34", "320", "9", etc
Digit \d \d\d.\d Will find "19.0", "23.4", "03.9", etc
Word \w .\w23 Will find ".M23", ".p23", ".A23", ".c23", etc
End of String $ 333$ Will find "1296-1333", "panda 333", "901-333", etc
Start of String ^ ^333 Will find "333 panda", "3330-4000", "333-901", etc
Replacing Expressions () and $1 Find: (=856.*\$u)(.*)(\$z.*) Replace: $1http://www.google.com$3 Will change "=856 \\$uhttp://library.brown.edu$zpublic note" to "=856 \\$uhttp://www.google.com$zpublic note"
Match Single character in a group [x] [aei] Will find "a" in "Gray" or "a" and "e" in "lane" or "i" in "kid"
Match single character in a group within a range between n and m [n-m] [A-Z] Will find "A", "C", "T", etc
Match single character not in a group [^x] [^aei] Will find "group", "loot", "hunt", etc