+ 2

I want to check if a string contains a list of letters how can i do that ?

9th Jun 2020, 4:29 PM
Grandizer
Grandizer - avatar
9 Answers
+ 1
Let's say you have a list with some Strings in it: for(String s : list){ if(yourString.contains(s){ //do something } }
9th Jun 2020, 6:13 PM
Denise RoƟberg
Denise RoƟberg - avatar
+ 4
Denise RoƟberg how can we do this with regex??
10th Jun 2020, 10:49 AM
hamid
hamid - avatar
+ 4
Denise RoƟberg thanks was so good learned more than just regex.
10th Jun 2020, 3:19 PM
hamid
hamid - avatar
+ 2
thx bro
9th Jun 2020, 6:16 PM
Grandizer
Grandizer - avatar
10th Jun 2020, 1:14 PM
Denise RoƟberg
Denise RoƟberg - avatar
+ 1
Hello Grandizer String has a contains() method. It returns true or false if a String contains a letter or a sequence. . contains ("a") .contains("abc") You only need to be careful with upper- and lowercase. (a != A)
9th Jun 2020, 4:55 PM
Denise RoƟberg
Denise RoƟberg - avatar
+ 1
Denise RoƟberg Ooh I was thinking of a method that check the string if it had a list of letters . And i can control the list
9th Jun 2020, 5:06 PM
Grandizer
Grandizer - avatar
+ 1
In this case you need a loop for each letter from the list.
9th Jun 2020, 6:09 PM
Denise RoƟberg
Denise RoƟberg - avatar
+ 1
Denise RoƟberg How to compare between a the list and string
9th Jun 2020, 6:11 PM
Grandizer
Grandizer - avatar