I have found very similar posts, but I can\'t quite get my regular expression right here.
I am trying to write a regular expression which returns a string which is b
Here's a regex which will grab what's between cow and milk (without leading/trailing space):
srctext = "My cow always gives milk."; var re = /(.*cow\s+)(.*)(\s+milk.*)/; var newtext = srctext.replace(re, "$2");
An example: http://jsfiddle.net/entropo/tkP74/