[Logo]
Forums Register Login
string digit testing
on line 12 I receive the error: Syntax error, insert ") Statement" to complete BlockStatements
I am trying to test the number of digits contained in the string
I can not think of any other ways of going about this.

This code block is incomplete

You have three ( and only two ). If you put another ) after before the { on line 12 then you will get past this error.
I'm not too sure how strong your regular expression knowledge is, but I do suspect that what you are trying could be done without loops and a correctly crafted regular expression.
I have found this site http://www.regexlib.com/ to be a good resource for regular expressions and they have a online regular expression tester.
is their a way to do this without regex,
in regards to checking whether or not the password contains a special character
 
kennith stomps wrote:is their a way to do this without regex, in regards to checking whether or not the password contains a special character

I'm sure that there is and that would require loops and if like you have started doing.
But, I'm not too sure what the exact code is.
1. Please indent and format your code.
2. Please remove useless comments.
3. Please re-post code after accomplish 1 and 2.
what about something like this?
if password contains any special character, terminate.
error is: Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
[]
//if password
if (password.contains("[^\w\.\,!""$%^&*\(\)-_+=::@']"){
}
[/code]
line 24 is giving me the error: This method must return a result of type boolean

this is the only route I can think of checking whether the string contains any special characters, by returning a boolean, however my boolean is not working? why is this?

 
if (password.contains("[^\w\.\,!""$%^&*\(\)-_+=::@']"){

This is a common mistake when coding regexes with Strings.  We forget that Strings can have escape characters.  So for instance, "\w" isn't a valid escape sequence in a String.  If we want a regex of \w in a String, we have to type "\\w" to escape the backslash.
 
kennith stomps wrote:line 24 is giving me the error: This method must return a result of type boolean

this is the only route I can think of checking whether the string contains any special characters, by returning a boolean, however my boolean is not working? why is this?

Is your code returning a boolean in all cases?
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Dec 11, 2017 08:09:10.