Monday, 12 June 2017

keep string between two words node js express

I have a string like:

var str = saGDJGJDJGlgk abc_start asjdgjgjgdfjakgfja abc_end csjhgfhsgfgfugvgjdj abc_start djkhfjwhjfgwjgkfvvg abc_end.

I'm displaying this string in my browser using:

res.send('/page/+result);

I want to filter out result such that only the content which starts at abc_start and end at abc_end remains. How do I do that in node.js?

For eg: output: abc_start asjdgjgjgdfjakgfja abc_end abc_start djkhfjwhjfgwjgkfvvg abc_end

I tried using : str.split('abc_start').pop().split('abc_end').shift();

But I'm not gettting desired output.Please help.



via user8151624

No comments:

Post a Comment