Collection of Regular Expressions (Regex) examples

Heiko Meyer
Heiko Meyer

Created: 12.10.2019 9:49 - Updated: 30.10.2020 9:52

Date (DD MM YYYY)

Find date (DD MM YYYY). Possible separators: ". / -"

Example text: Received on 22.01.2020

REGEX:

Result: 22.01.2020

Find day in (DD MM YYYY). Possible separators: ". / -"

Example text: Received on 22.01.2020

REGEX:

Result: 22

Find month in (DD MM YYYY). Possible separators: ". / -"

Example text: Received on 22.01.2020

REGEX:

Result: 01

Find year in (DD MM YYYY). Possible separators: ". / -"

Example text: Received on 22.01.2020

REGEX:

Result: 2020

Date (MM DD YYYY)

Find date (MM DD YYYY). Possible separators: ". / -"

Example text: Received on 01/22/2020

REGEX:

Result: 01/22/2020

Find month in (MM DD YYYY). Possible separators: ". / -"

Example text: Received on 01/22/2020

REGEX:

Result: 01

Find day (MM DD YYYY). Possible separators: ". / -"

Example text: Received on 01/22/2020

REGEX:

Result: 22

Find year in (MM DD YYYY). Possible separators: ". / -"

Example text: Received on 01/22/2020

REGEX:

Result: 2020

Date (YYYY MM DD)

Find date (YYYY MM DD). Possible separators: ". / -"

Example text: Received on 2020-01-22

REGEX:

Result: 2020-01-22

Find year in(YYYY MM DD). Possible separators: ". / -"

Example text: Received on 2020-01-22

REGEX:

Result: 2020

Find month in (YYYY MM DD). Possible separators: ". / -"

Example text: Received on 2020-01-22

REGEX:

Result: 01

Find day in (YYYY MM DD). Possible separators: ". / -"

Example text: Received on 2020-01-22

REGEX:

Result: 22

Amounts

Amount with decimal separated by comma

Example: total amount 12.345,67 euros

REGEX:

Result: 12.345,67

Amount with decimal separated by point

Example: Total amount 12,345.67 dollars

REGEX:

Result: 12,345.67

Text

Find specific content right from a word

Example: "(?<=Invoice\s).+" finds "I12345" in "Invoice I12345"

REGEX:

Result: I12345

Find specific content Left from a word

Example: ".+(?=\sInvoice)" finds" I12345 in "I12345 Invoice"

REGEX:

Result: I12345

Find specific content between two words

Example: "(?<=Invoice\s).+(?=\sDate)" finds "I12345" in "Invoice I12345 Date 01.01.2022"

REGEX:

Result: I12345

Was this article helpful?