Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.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 <;在正则表达式中后跟空格或不后跟空格_Javascript_Regex - Fatal编程技术网

Javascript <;在正则表达式中后跟空格或不后跟空格

Javascript <;在正则表达式中后跟空格或不后跟空格,javascript,regex,Javascript,Regex,我有一个多行文本框,如果我输入以下字符串: index a<3 2<x 索引a您可以使用\S匹配任何非空格字符(这是一个求反字符类的短处理程序,[^\S])。由于Javascript不支持look-behind,您需要匹配查看以下不带regex的方法(好的,在拆分中只使用了一点点regex) document.querySelector(“textarea”).addEventListener(“blur”,function()){ var值=此值; //console.log

我有一个多行文本框,如果我输入以下字符串:

index a<3

2<x

索引a您可以使用
\S
匹配任何非空格字符(这是一个求反字符类的短处理程序,
[^\S]
)。由于Javascript不支持look-behind,您需要匹配
查看以下不带regex的方法(好的,在
拆分中只使用了一点点regex)

document.querySelector(“textarea”).addEventListener(“blur”,function()){
var值=此值;
//console.log(值);
this.value=value.split(/\n |\r/).map(函数(项){

//console.log(item,item.split(/使用以下简单的正则表达式:
试试这个
'a
index a< 3

2< x
str = str.replace(/<(?=\S)/g, '< ');

// or with negative lookahead
str = str.replace(/<(?!\s)/g, '< ');