简体   繁体   中英

Regex doubt in Android (Java) code

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?

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM