Given the three formatted distance strings, how can I extract just the distance number?
x = "Max, 156km from you(001)"
a = "Nick, 66km from you(131)"
b = "Niclas, 76km from you(224)"
console.log(distance_from_x, distance_from_a, distance_from_b)
// Expected: (156,66,76)
This should work
const regex = /[0-9]+km/gm;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.