日常工作中常见的特殊字符,比如:
圆括号( :split("[(]")
符号:split("\")
斜杆():split("\\")
按位或符号(|):split("\|")
.dot:split("\.")
如果在一个字符串中有多个分隔符,可以用“|”作为连字符,比如"name=Bobandage=19andaddress=Beijing",把key和value都分隔出来,可以用split("=|and")
还有的复杂字符串,如果按常规操作,比如按逗号分隔,使用str.split(",")进行分隔,分隔出来的结果不是我们相像的一样,更不是我们想要的结果,比如下面的字符串:
String str = "{"symbol":"KZ","bc2":0,"bc1":0,"bc4":0,"current":null,"bc3":0,"bc5":0,"sc1":0,"bp1":0,"sc3":0,"sc2":0,"bp3":0,"sc5":0,"bp2":0,"sc4":0,"sellpct":0,"bp5":0,"bp4":0,"diff":0,"sp2":0,"sp1":0,"sp4":0,"sp3":0,"sp5":0,"time":1492128000000,"buypct":0,"ratio":0},{"data":{"market":{"status_id":2,"time_zone_desc":null,"region":"US","time_zone":"America/New_York","status":"盘前交易"},"quote":{"current_ext":null,"symbol":"KZ","high52w":null,"percent_ext":null,"delayed":0,"type":0,"tick_size":0.01,"float_shares":null,"high":null,"float_market_capital":null,"timestamp_ext":1611219316579,"lot_size":1,"lock_set":1,"chg":null,"eps":0.8583956470504864,"last_close":7.495,"profit_four":4.043329E7,"volume":null,"volume_ratio":null,"profit_forecast":4.5778666666666664E7,"turnover_rate":null,"low52w":null,"name":"空中网","exchange":"","pe_forecast":null,"total_shares":47103326,"status":0,"code":"KZ","goodwill_in_net_assets":26.62193188386609,"avg_price":null,"percent":null,"psr":null,"amplitude":null,"current":7.4