Regex extract text between pattern

YeppThat'sMe picture YeppThat'sMe · Jun 16, 2011 · Viewed 22.8k times · Source

i need your help with a regex in javascript.

I've got an a-tag with follow pattern

<a href='#'>
  <!--:de-->some german text<!--:--><!--:en-->some english text<!--:-->
</a>

So, now i'm searching for a regular expression what extract me each part

 1. <!--:de-->some german text<!--:-->
 2. <!--:en-->some german text<!--:-->

Thanks VERY much in advance

Answer

The Mask picture The Mask · Jun 16, 2011

Try this:

var str = '<!--:de-->some german text<!--:--><!--:en-->some english text<!--:-->'; 
var match =  str.match(/de-->([^<]+).+?en[^>]+>([^<]+)/i);
var textInDe = match[1]; 
var textInEn = match[2];