menu

arrow_back How can I check if a character is among the allowed ones without regular expression?

by
1 vote
Good afternoon!
How can I check if a character is among the allowed ones without regular expression?
There is an array of allowed characters (of all kinds) and should be that if the entered symbol is not equal to one of the allowed (located in the array), then was the exit from the cycle with an indication of this does not belong to a symbol.
I tried it, but it doesn't work that way, something is missing.
I would be glad for any help.
Thanks
So far it looks like this, but it doesn't work correctly

2 Comments

Code
for (int j = 0; j < arr.length; j++) {
if (code[i] == arr.alfabet[j]) {
check = false;
}else{
System.out.println("Unallowed symbol in position :" +code[i]);
check=true;}
}
Without seeing what you have already done it is unclear what the problem is, describe in more detail and the code in the studio

1 Answer

by
0 votes
Without regulars, you can do it like this:
create a method that takes char as an argument
iterate over an array of char characters.
In each iteration, check to see if the characters are early or not.
If there is no match, return false otherwise true