- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to test if a Java String contains a case insensitive regex pattern
the syntax? i:x makes the string search case-insensitive. for eg
public class RegCaseSense { public static void main(String[] args) { String stringSearch = "HI we are at java class."; // this won't work because the pattern is in upper-case System.out.println("Try this 1: " + stringSearch.matches(".*CLASS.*")); // the magic (?i:X) syntax makes this search case-insensitive, so it returns true System.out.println("Try this 2: " + stringSearch.matches("(?i:.*CLASS.*)")); } }
- Related Articles
- How to check if a String contains another String in a case insensitive manner in Java?
- How to extract a group from a Java String that contains a Regex pattern
- How to test if a string contains specific words in Java?
- Method to check if a String contains a sub string ignoring case in Java
- Check if a string contains only alphabets in Java using Regex
- How match a string irrespective of case using Java regex.
- How do we check if a String contains a substring (ignoring case) in Java?
- How to match a character from given string including case using Java regex?
- How do we make my string comparison case insensitive in java?
- How to check if a string contains only lower case letters in Python?
- How to check if a string contains only upper case letters in Python?
- How do I do a case insensitive string comparison in Python?
- MongoDB $regex operator i or I for case insensitive search
- Case-insensitive string comparison in C++
- Java Program to sort a List in case insensitive order

Advertisements