Regular Expression Examples


Example 1: vessel001

This simple pattern will match with all files that include vessel001 in their file name (For example, all of these will match: vessel001-wages.txt or dataio-vessel001.bin or new-vessel001-prod.txt)

Example 2: (.txt)$

This pattern will match the all files with the .txt file extensions which are just text files. ($ indicates look at the end of the file name. All of the following would match: file1.txt, data.txt, important-readme.txt)

Example 3: (.xlsx|.docx|.pub)$

This pattern will match files with xlsx, docx, or pub file extensions. This is a simple expression to match office document formats. Feel free to add more with the separator | . For example, if you want to add pdf files just change the expression to (.xlsx|.docx|.pub|.pdf)$

Example 4: ([binfer]\w*)+(.pdf|.txt)$

This pattern will match with all files that starts with ‘binfer’ and end with the pdf or txt file extensions(\w* indicates any one or more words)

Example 5: \d*

This pattern will match with any files that have a digit in their name, for example it matches with 123.txt or vessel-date-321.bin or hvac-0001.txt

For more information on how understand and write regex patterns visit https://regex101.com/