indexof case insensitive java

indexof case insensitive java

Hi,

I have to use the indexOf function on String class in Java. I am looking for indexof case insensitive java example. Share the code with me.

Thanks

View Answers

March 24, 2011 at 1:16 AM

Hi,

You can convert both the string into lowercase and then use indexOf method as shown below:

String s1 = str1.toLowerCase(Locale.US);
String s2 = str2.toLowerCase(Locale.US);
if(s1.indexOf(s2)!=-1){
  System.out.println("String found");
}else{
  System.out.println("String not found");
}

Thanks

Ads









Related Tutorials/Questions & Answers:
indexof case insensitive java
indexof case insensitive java  Hi, I have to use the indexOf function on String class in Java. I am looking for indexof case insensitive java... the string into lowercase and then use indexOf method as shown below: String s1
Hibernate Criteria Case Insensitive Search.
Hibernate Criteria Case Insensitive Search.  How to use Case Insensitive Search in Hibernate?   The Case Insensitive ignores the case... class Employee.java‚??Hibernate uses the Plain Old Java Object (POJO) classes
Advertisements
Case-insensitive ordering using Hibernate Criteria.
Case-insensitive ordering using Hibernate Criteria.  What is Case-insensitive ordering in Hibernate Criteria
Hibernate Criteria Case Insensitive
Hibernate Criteria Case Insensitive The Case Insensitive ignores the case of  the latter. It Selects all the records of the table related to the given... = criteria.list(); An example of Case insensitive is given below please consider
ModuleNotFoundError: No module named 'case_insensitive_dict'
ModuleNotFoundError: No module named 'case_insensitive_dict'  Hi...: No module named 'case_insensitive_dict' How to remove the ModuleNotFoundError: No module named 'case_insensitive_dict' error? Thanks   Hi
ModuleNotFoundError: No module named 'case_insensitive_dict'
ModuleNotFoundError: No module named 'case_insensitive_dict'  Hi...: No module named 'case_insensitive_dict' How to remove the ModuleNotFoundError: No module named 'case_insensitive_dict' error? Thanks   Hi
Case-insensitive equals using Hibernate Criteria.
Case-insensitive equals using Hibernate Criteria.  How to use Case-insensitive equals with Hibernate Criteria?   The Case Insensitive ignores the case of the latter. It Selects all the records of the table related
Case-insensitive search using Hibernate Query Language(HQL).
Case-insensitive search using Hibernate Query Language(HQL).  What is Case-insensitive search using Hibernate Query Language
ModuleNotFoundError: No module named 'odoo10-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo10-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo10-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo11-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo11-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo11-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo12-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo13-addon-auth-user-case-insensitive'
ModuleNotFoundError: No module named 'odoo13-addon-auth-user-case-insensitive...: ModuleNotFoundError: No module named 'odoo13-addon-auth-user-case-insensitive' How...-case-insensitive' error? Thanks   Hi, In your python
String indexOf() method in Java
String indexOf() method in Java In this tutorial we will discuss about indexOf() method in java. indexOf() method which is of string class,  used... for searching a specified character or string, indexOf() and lastIndex(). For example
Java : String Case Conversion
Java : String Case Conversion In this section we will discuss how to convert a String from one case into another case. Upper to Lower case Conversion : By using toLowerCase() method you can convert any upper case char/String
ModuleNotFoundError: No module named 'insensitive-dict'
ModuleNotFoundError: No module named 'insensitive-dict'  Hi, My... named 'insensitive-dict' How to remove the ModuleNotFoundError: No module named 'insensitive-dict' error? Thanks   Hi, In your
indexOf(Objekt o)
indexOf(Objekt o)  I have created a class, which contains 3 parameters; "l", "es1", "es2" public T(float l, float es1, float es2) { } I would then like to create a method, which returns me the index of a specific object
String indexOf() Method
String indexOf() Method      ... the indexOf() method of String class. We are going to use indexOf() method of String class in Java. The description of the code is given below for the usage
JavaScript indexOf substring
JavaScript indexOf substring... the JavaScript method indexOf(). When this method is called from the string object...: <html> <h2>Use of indexOf() method</h2> <script
String indexOf(String str)
about the indexOf(String str) method through the following java program... String indexOf(String str)     ... the indexOf(String str) method of String class. We are going to use indexOf(String str
How to integrate IBM case Manager with Java Applicarion(JSP or core java)
How to integrate IBM case Manager with Java Applicarion(JSP or core java)  Dear All, Its really important for me to demonstrate a POC (Proof of Concept) on integrating IBM Case Manager with Java Application. Any small help
String indexOf(int ch)
the indexOf(int ch) method through the following java program. In the program... String indexOf(int ch)      ... the indexOf(int ch) method of String class. We are going to use indexOf(int ch
Switch case in java
Switch case in java In this section we will learn about switch case in java..., and java, switch case is used . switch  is a selection control mechanism used... will illustrate the use of switch case in java: import java.util.Scanner; public
test case
test case  Hi Can you explain me how to write test case in java. regards kennedy
Switch Case in Java
. Switch statements with String cases are supported in Java SE 7 but the earlier version of Java did not support String in switch/case. Switch statements works... case will take place. Example of Switch Statement in Java: import java.io.
Write a java program to display the season given the month using switch case
Write a java program to display the season given the month using switch case  Write a java program to display the season given the month using switch case
How to trim string till indexof the string
How to trim string till indexof the string  how to trim string till indexof the string
Matching Case
Matching Case  Hi, i want some code for matching case from an text file. i.e if i give an query called Java from the user,i need to get an output searching the text file all the names in that without case sensitive
switch case instead of if else
switch case instead of if else  How to write code in switch case instead of if else in Java
String indexOf(int ch, int fromIndex)
about the indexOf(int ch, int fromIndex) method of String class. We are going to use indexOf(int ch, int fromIndex) method of String class in Java... String indexOf(int ch, int fromIndex)   
switch case
switch case  program to input 2 numbers and a choice.Using switch case we need to perform all the mathematical operation.Print a suitable error message if the choice is wrong

Ads