-2
如何用Java写的解析器以下字符串如何写解析器解析字符串中的Java
"SiteId:BLR232#Latitude:12.918444#Longitude:77.5940136#NetworkType:4g#Type:NONE#Type of Complaint:Call Drop#Sample Number:7022979575#Problem Description:agshjs vshsijsb#"
,这样结果输出将在HashMap中的Java
Key = SiteId, Value = BLR232
Key = Type, Value = NONE
Key = Problem Description, Value = agshjs vshsijsb
Key = Sample Number, Value = 7022979575
Key = NetworkType, Value = 4g
Key = Latitude, Value = 12.918444
Key = Type of Complaint, Value = Call Drop
Key = Longitude, Value = 77.5940136
我使用试过Pattern p = Pattern.compile("(\\w+):(\\w+)");
但不能正常工作,我需要。
我已经使用图案P = Pattern.compile尝试( “(\\ W +):(\\ W +)”);但不能正常工作,我需要 –
我认为['([^#:] +):([^#] +)'](https://regex101.com/r/kL9iY8/2)应该足够了。或者用'#'分割,然后用':'分割每个块。 –
或'([^:] +):([^#] +)#' –