29 lines
903 B
Java
29 lines
903 B
Java
package com.couplet.msg;
|
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
/**
|
|
* @author DongXiaoDong
|
|
* @version 1.0
|
|
* @date 2024/3/31 16:57
|
|
* @description
|
|
*/
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
String msgString = "VIN123456789DIJE41711764104506116.664380039.531990072.00031.3760000022000022000852000000D00809.600940000589066790930000203002030000044282.55000014000080700007440003000400095000058000054000011111111111111111";
|
|
|
|
//使用正则表达式匹配需要的部分
|
|
String pattern = "(.{17})(.{10})(.{4})(.{2})(.{2})";
|
|
Pattern compile = Pattern.compile(pattern);
|
|
Matcher matcher = compile.matcher(msgString);
|
|
|
|
if (matcher.find()) {
|
|
for (int i = 1; i <= matcher.groupCount(); i++) {
|
|
System.out.println("Group "+ i + ":" + matcher.group(i));
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|