wisetc / practice

Practice conclusion
5 stars 0 forks source link

web 增加文本对手机号的识别并增加拨号功能 #22

Open wisetc opened 5 years ago

wisetc commented 5 years ago

假设待处理的文本形如 '咖乐居社区咖乐居x栋xxx室 郭xxx 12310002000'

let { description } = this.props.workflow;
if (typeof description === 'string') {
  description = description.replace(/^(.*)(1\d{10})(.*)$/, (match, p1, p2, p3) => `${p1}<a href="tel:${p2}">${p2}</a>${p3}`);
}