I need to make a function that determines if a string has more than one character and that there is no "b" in it.
How could I? I have tried this:
public static boolean moreOneCharacterButB(String string) {
return string.matches(".{2,}&&^b");
}
Maybe I'm trying a nonsense, but I don't know very well how the issue of regular expressions is going.
Thanks for the help.
That a string has at least two characters and that all of them are different from "b" can be expressed as:
Where
^
indicates beginning,$
end and[^b]{2,}
"anything butb
" 2 or more times.