Javascript regex
Posted: Tue Oct 30, 2007 5:07 am
I have an associative PHP array that is all on 1 line. I want to get this array into a javascript array so what I figured I could do would be to split it up with regex. Basically I am trying to split it on something like this:
[ANY_2_UNDERCASE_LETTERS_A_TO_Z] =>
so a php array:
would get split into "stuff stuff stuff" and "asja asja asja". At least that is what I want. I have started trying to write the regex but it is not working at all. This is what I have (which returns no results)
any help is appreciated
[ANY_2_UNDERCASE_LETTERS_A_TO_Z] =>
so a php array:
Code: Select all
Array ( [en] => stuff stuff stuff [ee] => asja asja asja )Code: Select all
var expression = /(\[[a-z]\])/g;
var thing = expression.exec(text[7]);//text[7] is the 1 lined php array
for (var i = 0; i < thing.length; i++)
{
alert(thing[i]);
}