素胚勾勒不出你
您的正则表达式分析:"ˆ([\\d]+(\\.[\\d]{2})?\\|([A-Z]{2}){1})(,[A-Z]{2})*\\s(\\\".+\\\")?$"首先,让我们将 Java 字符串文字反转义为实际的正则表达式字符串:ˆ([\d]+(\.[\d]{2})?\|([A-Z]{2}){1})(,[A-Z]{2})*\s(\".+\")?$现在让我们把它分开:ˆ Incorrect character 'ˆ', should be '^' Match start of input, but your input starts with '['( [\d]+ The '[]' is superfluous, use '\d+' (\.[\d]{2})? Don't capture this, use '(?:X)?' \| ([A-Z]{2}){1} The '{1}` is superfluous, and don't capture just this) You're capturing too much. Move back to before '\|'(,[A-Z]{2})* Will only capture last ',XX'. Use a capture group around all the letters, then split that on ','\s(\".+\")? No need to escape '"', and only capture the content$ Match end of input, but your input ends with ']'因此,清理后它将是:^\[( \d+ (?:\.[\d]{2})?)\|( [A-Z]{2} (?:,[A-Z]{2})*)\s(?:"(.+)")?\]$一起回来:^\[(\d+(?:\.[\d]{2})?)\|([A-Z]{2}(?:,[A-Z]{2})*)\s(?:"(.+)")?\]$使用[15.00|GR,LQ,MD "Uber"]将捕获的输入:15.00- 全数GR,LQ,MD-split(",")用于获取数组{ "GR", "LQ", "MD" }Uber- 只是没有引号的文字请参阅regex101.com 上的演示。