javascript - How to create a Regular Expression which takes starting and ending point -


i want create regular expression takes starting , ending point , returns text between them.

for example:

<cite>www.weddingsandevents.<b>co.in</b>/album.<b>php</b>?<b>id</b>=2</cite> <cite>www.nsiccareers.<b>co.in</b>/general_document.<b>php</b>?<b>id</b>=27</cite> <cite>www.mrpc.<b>co.in</b>/users_article.<b>php</b>?<b>id</b>=3</cite> 

the above in string , want url between <cite></cite>

let testcases = [  '<cite>www.weddingsandevents.<b>co.in</b>/album.<b>php</b>?<b>id</b>=2</cite>',  '<cite>www.nsiccareers.<b>co.in</b>/general_document.<b>php</b>?<b>id</b>=27</cite>',  '<cite>www.mrpc.<b>co.in</b>/users_article.<b>php</b>?<b>id</b>=3</cite>'];    function getmatches(str){      let result = str.match(/<cite>(.*)<\/cite>/);      if(result){          console.log(result[1].replace(/<\/?b>/g, ''));                  return result[1].replace(/<\/?b>/g, '');      }      return null  }    for(let test of testcases){      getmatches(test);  }


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -