3

Can someone tell me exactly what is this regex doing?

new StringTokenizer(string,":/.@\\;,+ ");

I could not understand the exact meaning of this Regex, though it looks like something to do with splitting a string based on special characters?

3 Answers 3

6

StringTokenizer does not use regular expressions. The second parameter is a list of characters to be used as separators between tokens.

The JavaDoc says:

StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.

Sign up to request clarification or add additional context in comments.

Comments

1

StringTokenizer does not use regular expressions. The second argument is just the list of delimiters that it will use by default to split apart the string.

Comments

0

There is no regex in this code. the second argument is contains the list of the delimiters used to tokenize the string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.