validator_test.go 564 B

1234567891011121314151617181920
  1. package main
  2. import (
  3. "fmt"
  4. "regexp"
  5. "testing"
  6. )
  7. func TestVerify(t *testing.T) {
  8. // 输入的JSON字符串
  9. data := `{"id":"071995171560000000c40808","status":"highspeed","speed1":"35","speed2":"0","realtime":"2025-6-18 10:11:25","audio":"[m1]���ѳ��٣�������","vol":"6","play":"run","dis_content":"[pic3]#[pic4]","workmode":"normal"}`
  10. // 使用正则表达式提取 "speed1" 后面的数字
  11. re := regexp.MustCompile(`"speed1":"(\d+)"`)
  12. match := re.FindStringSubmatch(data)
  13. speed1 := match[1]
  14. fmt.Println("Speed1:", speed1)
  15. }