[英]Get content between first word and line break
I would like to get the value of a line between the first word and the line break at the end. 我想获得第一个单词和结尾处的换行之间的线的值。 for example:
例如:
foo bar bob
hello hi
I want to get "bar bob" by asking for line "foo". 我想通过询问“ foo”行来获得“ bar bob”。
I found it. 我找到了。
var str='foo bar baz'
var estr = str.replace(/^.*? (.*)/i,"$1" )
This will work for you 这对你有用
var str = "foo bar\n";
str.slice(str.indexOf(' ')+1,str.indexOf('\n')); //returns bar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.