How to read string regardless of Uppercase, Lowercase or mixed using Regex

Hi all, I am currently reading a text file containing invoice data extracted from a pdf file. I use Regex to extract strings which I need but recently I found a case which I wondered if was possible to read.
For example, strVar = Person Address #01-01

I would get the unit number using System.Text.RegularExpressions.Regex.Match(strVar,“(?<=(Person Address)).*”).Value

But if the “Person Address” is in full uppercase or full lowercase, the Regex code will not read the “#01-01”. How can I make it so that the Regex code is able to read the same words stated inside regardless of whether or not it is full uppercase, full lowercase or mixed?


Can you try System.Text.RegularExpressions.RegexOptions.IgnoreCase option as the following?

System.Text.RegularExpressions.Regex.Match(strVar,"(?<=(Person Address)).*",System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value


1 Like

Hi, @Yoichi
It worked! Thank you so much!


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.