javascript - How can i obtain a string between two specific strings using regex? -
I have such a string,
open calldifications of green 1 0 4 0 10.7kb 10.7kb Open Stockroom in green 1 0 3 8.6kb 8.6kb I have to get stockmill and calendered details from this. This is what I have tried to use regex,
var result = string.match (/ (?: Open) (. +) (?: 1) /) [1 ]; This is my absolute job:
router apps.cnter ("elasticindex", function ($ radius, es) {es.cat.indices (" B ", function (r, q) {string ct = string match (/ (?: Open) (. +) (?: 1) /) [1]; console log (r, q);}); }); This non-greedy (lazy) rijks should work instead: / Open + (. +?) + 1 / var result = string Match (/ Open + (. +?) +1 /) [1];
or safe view:
var result = (string.match (/ open + (. +?) + 1 /) || ['' , '']) [1];
Code:
var re = / open + (. +?) + 1 / g, matches = [] , Input = "green open calendered description 1 0 4 0 10.7 kb 10.7 kb green open stockpile 1 0 3 8.6 8.6 bills 8.6 kg"; Whereas (match = rexx) match. Push (match [1]); Console.log (matching);
Comments
Post a Comment