[英]get particular value from a string using javascript
using javascript how can i get 0e783d248f0e27408d3a6c043f44f337c54235ce
from below string 使用javascript如何从字符串下面获取
0e783d248f0e27408d3a6c043f44f337c54235ce
my console.log(stdout);
我的
console.log(stdout);
prints 版画
status.html:commit 0e783d248f0e27408d3a6c043f44f337c54235ce
The value 0e783d248f0e27408d3a6c043f44f337c54235ce
will be changing. 值
0e783d248f0e27408d3a6c043f44f337c54235ce
将会更改。
Am trying to find that key 我正在寻找那个钥匙
You can use split
function: 您可以使用
split
功能:
stdout.split("status.html:commit ")[1]
Or match
: 或
match
:
stdout.match("status.html:commit (.*)").pop()
If commit
is a constant, and you just need the rest of the string from commit
to the end, you can split the string on commit
and pop of the last part 如果
commit
是一个常量,并且只需要从commit
到结尾的其余字符串,则可以在commit
和最后一部分弹出时拆分字符串
string.split('commit').pop();
It will leave an extra space, but you can either trim that off, or just add a space in 它将留下一个额外的空间,但是您可以修剪掉它,或者只是在其中添加一个空间
split('commit ')
// ^ space
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.