{ "_longitude": 121.56993103027344, "_carrier": "中国移动", "_os": "iOS", "act_time_ts_ms": 1685260787010, "_province": "辽宁省", "keyword": "2023-05-28 09:39:52", "_app_version": "1.1.941", "_latitude": 38.981903076171875, "_os_version": "16.0", "platform_name": "享乐吧app", "_city": "大连市", "distinct_id": "744563", "_is_login_id": true, "_wifi": false, "_screen_height": 896, "_device_id": "862836ada98e476b371d1af8017dc59f", "event": "HeartBeat", "_screen_width": 414, "act_time": "2023-05-28 15:59:47", "_timezone_offset": -480, "_network_type": "", "_model": "iPhone12,1", "_ip": "223.102.57.42", "_country": "中国", "_manufacturer": "Apple" } java余元正则取出act_time_ts_ms的值
时间: 2023-07-02 15:18:19 浏览: 163
projects_v1.3.rar_matlab longitude_经度,维度
可以使用Java中的正则表达式来匹配字符串并提取act_time_ts_ms的值,示例代码如下:
```java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
String data = "{ \"_longitude\": 121.56993103027344, \"_carrier\": \"中国移动\", \"_os\": \"iOS\", \"act_time_ts_ms\": 1685260787010, \"_province\": \"辽宁省\", \"keyword\": \"2023-05-28 09:39:52\", \"_app_version\": \"1.1.941\", \"_latitude\": 38.981903076171875, \"_os_version\": \"16.0\", \"platform_name\": \"享乐吧app\", \"_city\": \"大连市\", \"distinct_id\": \"744563\", \"_is_login_id\": true, \"_wifi\": false, \"_screen_height\": 896, \"_device_id\": \"862836ada98e476b371d1af8017dc59f\", \"event\": \"HeartBeat\", \"_screen_width\": 414, \"act_time\": \"2023-05-28 15:59:47\", \"_timezone_offset\": -480, \"_network_type\": \"\", \"_model\": \"iPhone12,1\", \"_ip\": \"223.102.57.42\", \"_country\": \"中国\", \"_manufacturer\": \"Apple\" }";
String regex = "\"act_time_ts_ms\":\\s*(\\d+)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(data);
if (matcher.find()) {
String act_time_ts_ms = matcher.group(1);
System.out.println(act_time_ts_ms);
}
}
}
```
输出结果为:
```
1685260787010
```
阅读全文