Hi. I was wondering if anyone knows how to split a string. I did find a code on it; but it's based on a pattern.
Can anyone help me to split a string into letters..
e.g. "Like" --> "L", "i", "k", "e"
What about using the .toCharArray() method on String?
Mm..I found a way using Tokens. But does anyone now know like..taking in blanks, apostrophe, exclamation mark etc. and printing it out again?
Truth is; I'm trying to do a simple encryption method.
e.g. FLEE!! would be equals to NZAA!!
I've managed to split the words and change it but I do not know how to carry the !! or ' forward and output it..Anyone can help?
Currently for changing the output into a simple encryption I'm using if..else. If anyone has a better suggestion please comment ;)
Tokens? If you're using StringTokenizer, don't. Use the .toCharArray() method that hooknc mentioned.
Loop through each character using a FOR loop and determine if it's either a letter that should be changed or a symbol that should stay the same. You can do this by checking the characters' ASCII value.
int ascii = (int)character
if ((ascii > 64) && (ascii < 91))
//the character is between capital A and capital Z
You can use this link to see what number ranges alpha-numeric characters are in.