<< Click to Display Table of Contents >> RayPack > 7.3 u6 > User Guide > Reference and Cheat Sheets Regular Expressions Guide and Cheat Sheet |
Regular expressions (abbreviated to RegExp) are sequences of characters forming a search pattern that can be used to identify a textual material of a given pattern. The syntax of regular expression is standardized and used along many different products and operating systems, particularly for find and replace functionalities.
RayPack uses regular expressions to provide a flexible way of defining compact text conditions, which can be further customize to exclude and include particular resources based on complicated rules and logic.
The following cheat sheet presents some commonly used regular expression patterns and example patterns with explanation.
Phrase |
Description |
Examples |
---|---|---|
Letters or digits |
Literal meaning, case sensitive |
Abc matching Abc but not abc |
Pipe (|) |
Alternative |
A|b matching A, b, Ab but not BC |
Asterisk (*) |
Zero or more instances of the previous set |
A*b matching Aaaaab, Ab, bcd but not Ac A|b* matching a, b, bb, bbb but not CDE |
Plus (+) |
One or more instances of the previous set |
A+b matching Ab, AAAb but not b (a|b)+cd matching acd, bcd, aaacd, abcd, bacd but not cd Folder[0-9]+ matching Folder1, Folder2, Folder21 but not Folder or FolderA |
Question mark (?) |
Zero or one instance of the previous set |
Ab?(c|d) matching Ac, Ade, Abcd but not Abb |
Round brackets ( and ) |
Grouping of sets |
(abc|def)ghi matching abcghi, defghi, abcdefghi but not abcdef (a|b|c)?def matching adef, cdefghi, def but not abc |
Caret (^) |
On the beginning of the string marks that no characters are allowed before |
^abc matching abc, abcdef but not defabc ^(folder1|folder2|folder3)\\test matching folder1\test, folder2\test\test2 but not C:\folder1\test |
Dollar ($) |
At the end of the string marks that no characters are allowed after |
:\\test\\folder$ matching C:\test\folder, D:\test\folder but not C:\test\folder1 |
Square brackets [ and ] |
Allowed set of characters |
[a-z] matching abc, def but not 123 ^[A-D]:\\Test\\ matching C:\Test\ and D:\Test\ but not E:\Test\ folder[a-zA-Z0-9] matching folderA, folder1 but not folder\test |
Caret in square brackets [^] |
In square brackets – negation of character set |
C:\\folder[^\\]*\\test will match C:\folder\test but not C:\folder\subfolder\test |
Dot (.) |
Any character |
Folder.\\test will match FolderA\, Folder4\, Folder$\ but not Folder\ |
Backslash (\) |
Escape character |
C:\\test\\test2 matches C:\test\test2 but not C:\\test\\test2 Test\* matches Test* Test\(a\) matches Test(a) but not Testa |
(?i) |
Used at the beginning on the expression – do not match case |
(?i)abc will match abc, Abc, ABC123 but not 123 |
^(?i)(%windir%)\\Installer$
Matches |
Does not match |
---|---|
%windir%\Installer %windir%\INSTALLER |
%windir%\Installer\123-123.msi |
^(?i)%ProgramFiles\(x86\)%\\Common Files\\(InstallShield|Wise Installation)$
Matches |
Does not match |
---|---|
%ProgramFiles(x86)%\Common Files %ProgramFiles(x86)%\COMMON FILES |
%ProgramFiles(x86)%\Common Files\Microsoft %ProgramFiles%\Common Files\InstallShield %ProgramFiles(x86)%\Common Files\ %ProgramFiles(x86)%\Common Files\ |
^unins(|t|tall)\d*\.(cif|cfg|dat|dll|ini|exe|xml|lnk)$
Matches |
Does not match |
---|---|
uninst.exe uninst_myApp.lnk uninstallapp.cfg uninst.ini |
MyProgram_uninstall.cfg uninstall.txt unins.txt |
^_isreg32\.dll$
Matches |
Does not match |
---|---|
_isreg32.dll |
_ISREG32.dll isreg32.dll _isreg.dll _isreg32.dll.backup |
^(?i)(HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER)\\(Software\\Wow6432Node|Software)
\\InstallShield
Matches |
Does not match |
---|---|
HKEY_LOCAL_MACHINE\Software\InstallShield HKEY_LOCAL_MACHINE\Software\Wow6432Node HKEY_CURRENT_USER\SOFTWARE\Wow6432Node HKEY_CURRENT_USER\Software\INSTALLSHIELD |
HKEY_CLASSES_ROOT\Software\InstallShield HKEY_CURRENT_USER\Software |
^%USERPROFILE%\\(.+\\)?Temp$
Matches |
Does not match |
---|---|
%USERPROFILE%\Temp %USERPROFILE%\test\Temp %USERPROFILE%\test\test2\Temp |
%USERPROFILE%\Temp2 “%USERPROFILE%\Temp” %userprofile%\Temp |