Javascript 正向前瞻捕获太多JS
我正在努力在字符串中“notes:”之后出现的任何日期之前插入换行符。Javascript 正向前瞻捕获太多JS,javascript,regex,replace,replaceall,Javascript,Regex,Replace,Replaceall,我正在努力在字符串中“notes:”之后出现的任何日期之前插入换行符。 我的正则表达式似乎捕获了“notes:”之后第一个日期之前的所有文本 非常感谢您对JavaScript的任何帮助 const mystring = 'wed and thurs and notes: are just so interesting 02-03-2019 on a new line please 04-05-2020 on another line please' mystring.replaceAll(/(
我的正则表达式似乎捕获了“notes:”
之后第一个日期之前的所有文本 非常感谢您对JavaScript的任何帮助
const mystring = 'wed and thurs and notes: are just so interesting 02-03-2019 on a new line please 04-05-2020 on another line please'
mystring.replaceAll(/(?<=notes:).*?(\d{1,2}-\d{1,2}-\d{4})/g, function(capture){
return '<br>' + capture;
}
);
const mystring='wed和thurs and notes:非常有趣2019年03月02日换一行请2020年05月04日换一行请'
mystring.replaceAll(/(?您可以使用
const mystring='wed和thurs and notes:非常有意思2019年3月2日在一条新线路上请04-05-2020在另一条线路上请wed和thurs and notes:非常有意思2019年3月2日在一条新线路上请04/05/2020在另一条线路上请';
console.log(mystring.replace(/(?mystring.replace(/)您是否介意解释一下,我如何捕获带有“-”或“/”的日期,即2002年2月3日或2002年2月3日
wed and thrus and notes: are just so interesting <br> 02-03-2019 on a new line please <br> 04-05-2020 on another line please