前端使用正则表达式提取经纬度 度分秒值

经纬度:124°0′0.0″,我想提取度分秒

const regex = /(\d+\.\d+)°\s*(\d+\.\d+)′\s*(\d+\.\d+)″/;
const latMatches = record.latDegreeMinuteSecond.match(regex);
if (latMatches) {
  record.latDegree = latMatches[1]; // 提取度
  record.latMinute = latMatches[2]; // 提取分
  record.latSecond = latMatches[3]; // 提取秒
}

重要信息



posted @ 2025-05-29 21:44  刘大猫26  阅读(20)  评论(0)    收藏  举报