Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 正向前瞻捕获太多JS_Javascript_Regex_Replace_Replaceall - Fatal编程技术网

Javascript 正向前瞻捕获太多JS

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:”之后出现的任何日期之前插入换行符。
我的正则表达式似乎捕获了“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