---
title: "Regular expressions for document tagging"
canonical_url: "https://www.nutrient.io/guides/document-searchability/tagging/tips-and-faq/patterns-regular-expressions/"
md_url: "https://www.nutrient.io/guides/document-searchability/tagging/tips-and-faq/patterns-regular-expressions.md"
last_updated: "2026-06-01T16:54:29.762Z"
description: "Learn how to use regular expressions in tagging for accurate metadata extraction and document validation."
---

# Enhance document tagging with regular expressions

In Tagging, there a several places where you can specify patterns or regular expressions to constrain metadata that is extracted or tagged. Regular expressions enable you to apply formatting rules, check lengths, etc. to text to make sure they match a specific pattern. In essence, it validates the metadata before they are extracted from the document or tagged in SharePoint.

Here are some basic examples

| **Regular expression** | **Example matches**                                   | **Description**                                                          |
| ---------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------ |
| abc$                   | abc, 123abc                                           | Any text ending with abc                                                 |
| ^abc                   | abc, abc123                                           | Any text that starts with abc                                            |
| ^[0-9]{5}$             | 11111, 12345, 99999                                   | Any 5 digit numbers                                                      |
| \d{1,4}                | 1, 24, 445, 3333                                      | Any number that is 1 to 4 digits                                         |
| [A-Za-z]{4}-\d{4}      | ABCD-1234, GYDL-8450                                  | 4 letters followed by a dash, then 4 numbers                             |
| [A-Za-z]{4}[-_ ]\d{4}  | ABCD-1234, ABCD_1234, ABCD 1234                       | 4 letters followed either by a dash, underscore or space, then 4 numbers |
| [A-Za-z]{4}[\W_]\d{4}  | ABCD-1234, ABCD_1234, ABCD 1234, ABCD+1234, ABCD#1234 | 4 letters followed by any non-word separator, then 4 numbers             |

- [https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference](https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference)

- [https://msdn.microsoft.com/en-us/library/ms972966.aspx](https://msdn.microsoft.com/en-us/library/ms972966.aspx)

- [https://msdn.microsoft.com/en-us/library/ff650303.aspx](https://msdn.microsoft.com/en-us/library/ff650303.aspx)

Some useful regular expressions taken from the resources above:

| **Field**                       | **Regular expression**                          | **Example matches**                | **Description**                                                                                                                                                                                                     |
| ------------------------------- | ----------------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Social Security Number          | ^\d{3}-\d{2}-\d{4}$                             | 111-11-1111                        | Validates the format, type, and length of the supplied input field. The input must consist of 3 numeric characters followed by a dash, then 2 numeric characters followed by a dash, and then 4 numeric characters. |
| Phone Number                    | ^[01]?[-.]?(([2-9]\d{2})                       | [2-9]\d{2})[-.]?\d{3}[-.]?\d{4}$ | (425) 555-0123, 425-555-0123, 425 555 0123, 1-425-555-0123                                                                                                                                                          |
| E-mail                          | ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$ | someone@example.com                | Validates an e-mail address.                                                                                                                                                                                        |
| ZIP Code                        | ^(\d{5}-\d{4}                                   | \d{5}                              | \d{9})$                                                                                                                                                                                                             |
| Currency (non-negative)         | ^\d+(.\d{2})?$                                  | 1.00                               | Validates a positive currency amount. If there is a decimal point, it requires 2 numeric characters after the decimal point. For example, 3.00 is valid but 3.1 is not.                                             |
| Currency (positive or negative) | ^(-)?\d+(.\d{2})?$                              | 1.20, -1.20                        | Validates for a positive or negative currency amount. If there is a decimal point, it requires 2 numeric characters after the decimal point.                                                                        |

---

## Related pages

- [Master document searchability with expert tips](/guides/document-searchability/tagging/tips-and-faq.md)
- [Understanding tag limits in SharePoint](/guides/document-searchability/tagging/tips-and-faq/tag-limits.md)
- [Document Searchability guides and support tips](/guides/document-searchability/tagging/tips-and-faq/help--support.md)
- [Integrate Document Searchability OCR with Tagging](/guides/document-searchability/tagging/tips-and-faq/running-searchlight-tagger-with-searchlight-ocr.md)
- [Understanding entity extraction and its benefits](/guides/document-searchability/tagging/tips-and-faq/entity-extraction-nlp.md)
- [Customize your document types with ease](/guides/document-searchability/tagging/tips-and-faq/document-types.md)
- [Understanding tokenization for effective tagging](/guides/document-searchability/tagging/tips-and-faq/tokenization.md)
- [Managing SharePoint columns in tagging](/guides/document-searchability/tagging/tips-and-faq/sharepoint-columns.md)

