---
title: "How to make a regex match case insensitive?"  
description: "How to make a regex match case insensitive?"  
author: "Anonymous User"  
published: 2014-02-03  
updated: 2014-02-03  
canonical: https://www.mindstick.com/forum/1946/how-to-make-a-regex-match-case-insensitive  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How to make a regex match case insensitive?

I have following [regular expression](https://www.mindstick.com/articles/11909/java-regex-or-regular-expression-in-java) for postal [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) of Canada.

^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$

It is [working fine](https://answers.mindstick.com/qa/95550/why-is-the-safari-browser-not-working-fine) but accepts only [Capital letters](https://answers.mindstick.com/qa/92915/do-capital-letters-matter-in-urls). I want it work for both capital and small letters.

## Replies

### Reply by Pravesh Singh

Hi Samuel,\

Just use the option IgnoreCase,

So your regex creation could look like this

```
Regex r = new Regex(@"^[ABCEGHJKLMNPRSTVXY]\d[A-Z]
*\d[A-Z]\d$", RegexOptions.IgnoreCase);
```

I removed also all your {1} because it is superfluous. Every item is per default matched once, no need to state this explicitly.


---

Original Source: https://www.mindstick.com/forum/1946/how-to-make-a-regex-match-case-insensitive

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
