I might use String#matches() here, with a regex alternation:

CopyString input = "cpr1210";
if (input.matches("(?i).*(?:cpr|cvr|nr).*")) {
    System.out.println("MATCH");
}

If you really wanted to use String#contains(), then you would need to have three separate calls to that method, for each sequence.

Answer from Tim Biegeleisen on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
October 20, 2025 - Trailing empty strings are therefore not included in the resulting array. The string "boo:and:foo", for example, yields the following results with these expressions: ... the array of strings computed by splitting this string around matches of the given regular expression ... Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter. ... String message = String.join("-", "Java...
🌐
W3Schools
w3schools.com › java › ref_string_contains.asp
Java String contains() Method
The contains() method checks whether a string contains a sequence of characters. Returns true if the characters exist and false if not. ... The CharSequence interface is a readable sequence of char values, found in the java.lang package.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-contains-method-example
Java String contains() Method with Example - GeeksforGeeks
July 11, 2025 - ... // Java Program to demonstrate working contains() method class Gfg { public static void main(String args[]) { String s = "My name is GFG"; System.out.println(s.contains("GFG")); System.out.println(s.contains("geeks")); } }
🌐
CodeGym
codegym.cc › java blog › strings in java › java string contains() method
Java String contains() Method
January 8, 2025 - You can use the contains(String key) method to “find” if a certain string “key” is present within a certain string or not. If “key” is found, “true” is returned. Else you will get a “false”. This method is already implemented ...
🌐
Baeldung
baeldung.com › home › java › java string › java string.contains()
Java String.contains() | Baeldung
April 11, 2025 - • Java String.String() • Java ... String.toUpperCase() • Java String.trim() • Java String.valueOf() The method contains() checks if a String contains another String....
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › String › contains
Java String contains() - Check If Contains Substring | Vultr Docs
November 19, 2024 - The contains() method in Java is a crucial function for string manipulation, used extensively to determine whether a particular substring exists within another string.
🌐
Programiz
programiz.com › java-programming › library › string › contains
Java String contains()
class Main { public static void main(String[] args) { String str1 = "Learn Java"; Boolean result; // check if str1 contains "Java" result = str1.contains("Java"); System.out.println(result); // true // check if str1 contains "Python" result = str1.contains("Python"); System.out.println(result); // false // check if str1 contains ""
Find elsewhere
🌐
BeginnersBook
beginnersbook.com › 2017 › 10 › java-string-contains-method
Java String contains() method
Java String contains() method checks whether a particular sequence of characters is part of a given string or not.
🌐
Javatpoint
javatpoint.com › java-string-contains
Java String.contains() Method
Java String contains() method with method signature and examples of concat, compare, touppercase, tolowercase, trim, length, equals, split, string contains in java etc.
🌐
TechVidvan
techvidvan.com › tutorials › java-string-contains-method
Java String contains() Method - TechVidvan
March 4, 2024 - In the following program, we create an object of class string with the value “HelloWorld”. Then we create a sequence of characters with the value “helo”. Using the contains() method, we try to check whether the given string contains the specified sequence of characters or not. import ...
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › lang › String.html
String (Java SE 11 & JDK 11 )
January 20, 2026 - Trailing empty strings are therefore not included in the resulting array. The string "boo:and:foo", for example, yields the following results with these expressions: ... the array of strings computed by splitting this string around matches of the given regular expression ... Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter. ... String message = String.join("-", "Java...
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › string.contains() method in java
String.contains() Method in Java
September 1, 2008 - It returns the Boolean value, which is true if and only if the string contains the sequence of char values; false otherwise. The contains () method accepts a character sequence as an argument. It throws an exception if one of the sequence contains null value. A char sequence is readable sequence of the character values. Following is the syntax of the Java String contains() method −
🌐
Blogger
javarevisited.blogspot.com › 2016 › 10 › how-to-check-if-string-contains-another-substring-in-java-indexof-example.html
How to check if String contains another SubString in Java? contains() and indexOf() example
Also, if you are learning Java from scratch then I suggest sticking with a good book like Java: How to Program by Dietel to learn fundamentals before jumping around. ... Unknown said... ... Anonymous said... In my case .contains(),isExist are not working and also no error showing to me after using it. I have set of url and I have substring to search from that URL and print wheater it is exist or not ... Unknown said... You made a mistake in article Searching using contains section : String test = "Java8 makes Java more powerful"; boolean isFound = test.contains("Java8"); #text
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › String.html
String (Java SE 17 & JDK 17)
January 20, 2026 - Trailing empty strings are therefore not included in the resulting array. The string "boo:and:foo", for example, yields the following results with these expressions: ... the array of strings computed by splitting this string around matches of the given regular expression ... Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter. ... String message = String.join("-", "Java...
🌐
Guru99
guru99.com › home › java tutorials › java string contains(): check if string contains substring
Java String contains(): Check if String contains Substring
November 8, 2024 - For example, If you want to test if the String “The big red fox” contains the substring “red.” The string contains() in Java method is useful in such situation.
🌐
Scaler
scaler.com › home › topics › contains() in java
contains() in Java | contains() Function in Java - Scaler Topics
May 5, 2024 - contains () method is a built-in Java method that helps us check if a sequence of characters is present inside a given string or not. The return type of this method is boolean, thus returning true or false.
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java string contains() method tutorial with examples
Java String contains() Method Tutorial With Examples
April 1, 2025 - In the above example, you can see the first print statement that returns true as “Java” is a part of the main String str. The second and third print statement returns false due to the character case and sequence mismatch.