Skip to main content
Solved

Document Automation extract field using regex that not case sensitive

  • Mar 19, 2026 11:38 AM UTC
  • 1 reply
  • 46 views

I am trying to find the string “tax invoice” on documents, but I need to make the regex case insensitive. Google keeps telling me to use (?i)tax invoice but the TEST REGEX PATTERN does not seem to accept this syntax. 
 

I am hoping that someone can provide some guidance on the support regex syntax library.

 

Thanks in advance, 

Cameron 

Best answer by devendeshpande

The Core Issue

The (?i) inline flag is a Java/Python/Perl regex syntax that Google commonly references. However, Automation Anywhere uses the .NET regex engine (specifically the System.Text.RegularExpressions library from Microsoft .NET Framework). While .NET regex does support (?i), the way it is implemented in the AA Test Regex Pattern dialog and certain package contexts can be inconsistent or restrictive.

Solution 1: Use .NET Inline Flag Correctly (Preferred)

In .NET regex, the correct inline case-insensitive flag syntax is:

(?i)tax invoice

OR equivalently:

(?i:tax invoice)

If (?i)tax invoice is not working in the Test Regex Pattern dialog, try the grouped/scoped version:

(?i:tax invoice)

This applies the case-insensitive flag only to the group, which is more explicitly scoped and may be better accepted by AA's regex tester.

Solution 2: Use a Character Class for Each Letter (Most Reliable)

This approach works regardless of which regex engine or flag support is available — it is universally compatible:

[Tt][Aa][Xx]\s[Ii][Nn][Vv][Oo][Ii][Cc][Ee]

Breakdown:

Pattern Matches
[Tt] T or t
[Aa] A or a
[Xx] X or x
\s Any whitespace (space, tab)
[Ii] I or i
[Nn] N or n
[Vv] V or v
[Oo] O or o
[Ii] I or i
[Cc] C or c
[Ee] E or e

This is 100% compatible with AA's regex engine and the Test Regex Pattern dialog.

Solution 3: Use Alternation for Mixed Case Variants

If you know the common casing variants, use alternation:

[Tt]ax [Ii]nvoice|TAX INVOICE|tax invoice|Tax Invoice|TAX Invoice

Or more elegantly with grouping:

(?:tax|Tax|TAX)\s(?:invoice|Invoice|INVOICE)

Solution 4: Use (?i) Flag in the String Package – Regex Match Action

If you are using the String: Matches Regex or String: Extract actions in AA, the (?i) flag behavior may differ from the Test Regex Pattern dialog. Try placing the flag at the very beginning of the pattern with no spaces:

(?i)tax\sinvoice

Or with a flexible whitespace match (handles multiple spaces or tabs between words):

(?i)tax\s+invoice

Solution 5: Normalize the String Before Regex (Alternative Approach)

Instead of making the regex case-insensitive, convert the source string to lowercase first, then match against a lowercase pattern:

String: To Lowercase → $DocumentText$ → Store in $LowercaseText$

String: Matches Regex
String: $LowercaseText$
Pattern: tax\s+invoice

This completely sidesteps the case-sensitivity issue and works reliably in all AA regex contexts.

All Pattern Options – Summary

Pattern Approach Compatibility
(?i)tax invoice .NET inline flag May not work in AA Test dialog
(?i:tax invoice) .NET scoped inline flag Try this if above fails
[Tt][Aa][Xx]\s[Ii][Nn][Vv][Oo][Ii][Cc][Ee] Character class 100% compatible
(?:tax|Tax|TAX)\s(?:invoice|Invoice|INVOICE) Alternation Fully compatible
(?i)tax\s+invoice Flag + flexible space Test in your version
Lowercase string first → tax\s+invoice Pre-processing 100% reliable

Additional Tips for Document Processing

Since you are searching for "tax invoice" in documents (likely using IQ Bot / Document Automation or string extraction):

Use \s+ instead of \s or a literal space — this handles multiple spaces, tabs, or irregular spacing that often appears in scanned/OCR'd documents:

[Tt][Aa][Xx]\s+[Ii][Nn][Vv][Oo][Ii][Cc][Ee]

If the document may have line breaks between "tax" and "invoice":

[Tt][Aa][Xx][\s\r\n]+[Ii][Nn][Vv][Oo][Ii][Cc][Ee]

If OCR may introduce noise characters between letters:

[Tt].{0,2}[Aa].{0,2}[Xx]\s+[Ii].{0,2}[Nn][Vv][Oo][Ii][Cc][Ee]

Recommended Pattern for Your Use Case

Based on your scenario, the most reliable and universally compatible pattern to use in AA is:

[Tt][Aa][Xx]\s+[Ii][Nn][Vv][Oo][Ii][Cc][Ee]

And if you want to pre-process the string, use:

String: To Lowercase → then match: tax\s+invoice

References

  • AA String Package / Regex: https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/aae-client/bot-creator/commands/string-package.html
  • AA Regex Test Pattern: https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/aae-client/bot-creator/commands/regex-package.html
  • .NET Regex Reference: https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference
View original
This topic has been closed for replies.

1 reply

Forum|alt.badge.img
  • Automation Anywhere Team
  • Answer
  • Oct 15, 2026 8:18 PM UTC

The Core Issue

The (?i) inline flag is a Java/Python/Perl regex syntax that Google commonly references. However, Automation Anywhere uses the .NET regex engine (specifically the System.Text.RegularExpressions library from Microsoft .NET Framework). While .NET regex does support (?i), the way it is implemented in the AA Test Regex Pattern dialog and certain package contexts can be inconsistent or restrictive.

Solution 1: Use .NET Inline Flag Correctly (Preferred)

In .NET regex, the correct inline case-insensitive flag syntax is:

(?i)tax invoice

OR equivalently:

(?i:tax invoice)

If (?i)tax invoice is not working in the Test Regex Pattern dialog, try the grouped/scoped version:

(?i:tax invoice)

This applies the case-insensitive flag only to the group, which is more explicitly scoped and may be better accepted by AA's regex tester.

Solution 2: Use a Character Class for Each Letter (Most Reliable)

This approach works regardless of which regex engine or flag support is available — it is universally compatible:

[Tt][Aa][Xx]\s[Ii][Nn][Vv][Oo][Ii][Cc][Ee]

Breakdown:

Pattern Matches
[Tt] T or t
[Aa] A or a
[Xx] X or x
\s Any whitespace (space, tab)
[Ii] I or i
[Nn] N or n
[Vv] V or v
[Oo] O or o
[Ii] I or i
[Cc] C or c
[Ee] E or e

This is 100% compatible with AA's regex engine and the Test Regex Pattern dialog.

Solution 3: Use Alternation for Mixed Case Variants

If you know the common casing variants, use alternation:

[Tt]ax [Ii]nvoice|TAX INVOICE|tax invoice|Tax Invoice|TAX Invoice

Or more elegantly with grouping:

(?:tax|Tax|TAX)\s(?:invoice|Invoice|INVOICE)

Solution 4: Use (?i) Flag in the String Package – Regex Match Action

If you are using the String: Matches Regex or String: Extract actions in AA, the (?i) flag behavior may differ from the Test Regex Pattern dialog. Try placing the flag at the very beginning of the pattern with no spaces:

(?i)tax\sinvoice

Or with a flexible whitespace match (handles multiple spaces or tabs between words):

(?i)tax\s+invoice

Solution 5: Normalize the String Before Regex (Alternative Approach)

Instead of making the regex case-insensitive, convert the source string to lowercase first, then match against a lowercase pattern:

String: To Lowercase → $DocumentText$ → Store in $LowercaseText$

String: Matches Regex
String: $LowercaseText$
Pattern: tax\s+invoice

This completely sidesteps the case-sensitivity issue and works reliably in all AA regex contexts.

All Pattern Options – Summary

Pattern Approach Compatibility
(?i)tax invoice .NET inline flag May not work in AA Test dialog
(?i:tax invoice) .NET scoped inline flag Try this if above fails
[Tt][Aa][Xx]\s[Ii][Nn][Vv][Oo][Ii][Cc][Ee] Character class 100% compatible
(?:tax|Tax|TAX)\s(?:invoice|Invoice|INVOICE) Alternation Fully compatible
(?i)tax\s+invoice Flag + flexible space Test in your version
Lowercase string first → tax\s+invoice Pre-processing 100% reliable

Additional Tips for Document Processing

Since you are searching for "tax invoice" in documents (likely using IQ Bot / Document Automation or string extraction):

Use \s+ instead of \s or a literal space — this handles multiple spaces, tabs, or irregular spacing that often appears in scanned/OCR'd documents:

[Tt][Aa][Xx]\s+[Ii][Nn][Vv][Oo][Ii][Cc][Ee]

If the document may have line breaks between "tax" and "invoice":

[Tt][Aa][Xx][\s\r\n]+[Ii][Nn][Vv][Oo][Ii][Cc][Ee]

If OCR may introduce noise characters between letters:

[Tt].{0,2}[Aa].{0,2}[Xx]\s+[Ii].{0,2}[Nn][Vv][Oo][Ii][Cc][Ee]

Recommended Pattern for Your Use Case

Based on your scenario, the most reliable and universally compatible pattern to use in AA is:

[Tt][Aa][Xx]\s+[Ii][Nn][Vv][Oo][Ii][Cc][Ee]

And if you want to pre-process the string, use:

String: To Lowercase → then match: tax\s+invoice

References

  • AA String Package / Regex: https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/aae-client/bot-creator/commands/string-package.html
  • AA Regex Test Pattern: https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/aae-client/bot-creator/commands/regex-package.html
  • .NET Regex Reference: https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference