Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
91
rated 0 times [  95] [ 4]  / answers: 1 / hits: 64622  / 13 Years ago, fri, june 17, 2011, 12:00:00

First of all, here is my code snippet:



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];


I've got this regex validation (thanks to The Mask) which works great.



Now, I want to check with an if-statement if this regex applies to some string or not.
I'm using Javascript jquery.



Thanks in advance :)


More From » jquery

 Answers
4

You can use RegExp.test



if(/de-->([^<]+).+?en[^>]+>([^<]+)/i.test(str)) {
// something
}

[#91653] Thursday, June 16, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
longd

Total Points: 616
Total Questions: 110
Total Answers: 101

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
;