By continuing to use this site, you agree to the storing of first- and third-party cookies on your device to enhance site navigation; analyze site, product, and service usage; and assist in our marketing and promotional efforts. Cookie Policy

 
Skip to Content

Regex

Regex, short for "regular expression," is a sequence of characters that set a pattern used to define either the allowed or disallowed characters and character strings in a naming convention. Regex can define characters, cases, symbols, naming structures, and lengths.

Regex is used throughout OU Campus, in locations such as site settings for file naming and binary file naming, and find and replace.

File NamingLink to this section

Use following regex in file naming settings to restrict which characters are allowed to users when naming files.

Symbol Description Sample Regex Sample Definition Examples
[ - ] Range indicator [a-z] One lower case (LC) letter from a thru z d, or a, or z
[ - ] Range indicator [a-zA-Z] One LC or upper case (UC) letter D, or d, or A
[ - ] Range indicator [a-zA-Z0-9] One LC, UC, or number(#) d, or D, or 1
* No limit in characters [a-zA-Z]* Any LC or UC of any length LongfileName
{ } Set Character Limit [a-zA-Z]{5} Any LC or UC exactly 5 characters in Length aaaaa, AasAc, hhhhH
{ , } Set Character Range [a-zA-Z]{2,5} Any LC or UC between 2 to 5 characters in Length aAa, abCd, abcdE
{ , } Set Minimum Character Range [a-zA-Z]{2,} Any LC or UC a minimum of 2 characters in Length aaa, ababA, Filename
[ - ]*[ . ] Add required punctuation [a-zA-Z]*[.] Any LC or UC of any length ending in a . test. Sample. nAme.
[ - ]*[ . ][ - ] Add defined extension rules [a-zA-Z]*[.] [a-z] Any LC or UC of any length ending with a . with an extension of 1 character made of any LC a-z test.a, name.b, words.c
[ - ]*[ . ][ - ]{ , } Add a range for the extension [a-zA-Z]*[.] [a-z]{2,4} Any LC or UC of any length ending with a . with an extension of 2 to 4 characters made of any LC a-z Name.tif, image.jpg, document.docx
[|] Boolean, 'or' [a-zA-Z]*[.] [jpg|jpeg|txt|pdf]{3,4} Any LC or UC of any length ending with a . with an extension limited to jpg, jpeg, txt, or pdf image.jpg, image.jpeg, doc.txt, doc.pdf
\ Add restricted Character [a-zA-Z\-]*[.] [a-z]{2,4} Any LC or UC or - of any length ending with a . with an extension of 2 to 4 characters made of any LC a-z image-new.jpg

* LC = lower case, UC = upper case

Use the following regex when searching (such as a find and replace with regex) to find content that fits criteria more complicated than simple text matches.

Symbol Description Sample Regex Sample Definition Examples
[] Search Range [z] Search for any lower case z PEz, zebrA
( ) Search Group (pdf) Look for any grouping of pdf in filenames or code document.pdf, /xsl/catalog/pdf/courses
\. Special Character (\.pdf) Look for any grouping that includes .pdf document.pdf, file.pdf
^ Negated, Not [^A-Z] Match everything that is NOT an uppercase A-Z This is an Example of This REgEX
? Match as few characters as possible ([o]{2}?) Match any word that has two o's next to each other Footcode, Prefooter,
(|) Boolean, "or" (jpg|gif|pdf) Match any of the sequences of text image.jpg, document.pdf, file.gif