Making RegEx searches case-insensitive

I’m using 1.1 with Visual Studio 2003 (   I have a program that checks a url to make sure it’s valid and that it is a pdf file.  What I want to do is make it so the check is case-insensitive.  Below you can see how I used “[pP][dD][fF]” to make the search for “pdf” case-insensitive, but I don’t want to do it that way (I may want to later make other parts case-insensitive).

I see in the Help that there is an “IgnoreCase” option, but I don’t know how to utilize it.

The first line below makes the url criteria, then the conditional statement checks to see if the url is how I require it to be.  But I don’t see how to make it case-insensitive.  I don’t see how I would use “urlRegEx.Options.IgnoreCase”.  Can you help?  Thank you!

(pdfFileUrl is the url itself)

        urlRegEx = New Regex("^(http[s]?://).+[pP][dD][fF]$")
            If urlRegEx.IsMatch(pdfFileUrl) Then
                Trace.Warn("urlRegEx", "Url should be okay.")
                Trace.Warn("urlRegEx", "Url failed!")
            End If
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Harisha M GEngineerCommented:
Hi, try this:

urlRegEx.IsMatch(pdfFileUrl, RegEx.Options.IgnoreCase)

Fernando SotoRetiredCommented:
Hi psmithphil;

Just change this line in your code

urlRegEx = New Regex("^(http[s]?://).+[pP][dD][fF]$")

To this:

urlRegEx = New Regex("^(http[s]?://).+pdf$", RegexOptions.IgnoreCase)


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
psmithphilAuthor Commented:
Thank you both!

Fernando, what you showed me worked perfectly.  Now that I see it, I can see why it would work.  Mgh's was close but it wouldn't show up in Intellisense so it wasn't available.

This makes life a lot easier.  Thank you!
Fernando SotoRetiredCommented:
Glad I was able to help. :=)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.