Given that string
is a String
, what does string.split("[\\t]");
do? I don't understand what the brackets are for. Thanks!
string.split("[\\t]");
will split the string into an array of strings with a Tab being the separating character. The brackets are for defining a construct regex pattern or a character class, and with only one character they're actually not needed. Here is an example
It is the same as string.split("\\\\t");
but I guess some people find it easier to read.
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.