I have one variable holding single line string which is html element like this.
var des = "<p> --Sometext before-- FI: This is fi name, This is fi manufacturer <br /> SE:This is se name, This is se manufacturer <br /> EN: This is en name, This is en manufacturer</p>";
I want to select everything after FI: until comma sign into one variable and after comma sign until
tag into another variable. Also for SE: and EN: too.
For example, result will be like this.
var fi_name = "This is fi name";
var fi_manufacturer = "This is fi manufacturer";
var se_name = "This is se name";
var se_manufacturer = "This is se manufacturer";
var en_name = "This is en name";
var en_manufacturer = "This is en manufacturer";
Note, the string change dynamically but still have same pattern.
For example:
<p> --Sometext before-- FI:[name],[manufacturer]<br/ >SE:[name],[manufacturer]<br/ >FI:[name],[manufacturer]</p>
You can have a look at demo in JsFiddle.
Now it’s throwing null error.
Edited v v v
It’s not working in live website. The des variable is fully look like this.
Please see http://jsfiddle.net/AM8X2/ It’s throwing null again.
I changed your jsFiddle to this:
http://jsfiddle.net/11684/raPDd/4/
I added upper case letters and spaces and comma’s to your regex, so it doesn’t return null (because no match was found) and the rest was fine.
The result:
EDIT:
I didn’t see you needed the name and manufacturer in separate variables, I edited the fiddle: http://jsfiddle.net/11684/raPDd/5/ to this: