I've been trying to create a regex which would ignore the casing.
This is the regex i am trying to use:
/^[A-Za-z0-9._+\-\']+@+test.com$/;
So basically i would want to match any of these
I tried this, but it doesn't work:
/^[A-Za-z0-9._+\-\']+@+(?i)+test.com$/;
I read somewhere about the use of (?i), but couldn't find any examples which show their usage in regex to ignore casing. Thoughts anyone ? Thanks a lot in advance.
re. IGNORECASE : This flag allows for case-insensitive matching of the Regular Expression with the given string i.e. expressions like [A-Z] will match lowercase letters, too. Generally, It's passed as an optional argument to re.
Search patterns are made up of a sequence of characters and can be specified using regex rules. However, to work with regular Python expressions, you first need to import the re module. Case insensitive means that the text should be considered equal in lowercase and uppercase.
Case Insensitive Search By default, grep is case sensitive. This means that the uppercase and lowercase characters are treated as distinct. To ignore case when searching, invoke grep with the -i option (or --ignore-case ).
Flags go at the end.
/regex/i
i
is for case-Insensitive (or ignore-case)
For anyone else who arrives here looking for this, if you've got code that is using the RegExp
constructor you can also do this by specifying flags as a second argument:
new RegExp(pattern[, flags])
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp
For example:
var pattern = /^[A-Za-z0-9._+\-\']+@+test.com$/; var regExp = new RegExp(pattern, "i");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With