S
sthussey
So I'm trying to write a WDDX deserializer (I know they exist, but I'm
not fond of what I've seen) and so far everything is hunky dory.
Rather than writing a full lexical analyzer, I'm just using RE's to
match the pieces of the WDDX schema that I care about. And everything
works except for the the recordset element. Below is the string I'm
trying to match and expression I'm using. The RE matches and populates
$2 and $3 with the correct captures, but $1 is left undefined. If I
switch the order of the rowCount and fieldNames attributes of the
recordset element, then the RE matches and populates all three
captures correctly. Any ideas?
var testString = " <recordset rowCount='2'
fieldNames='FIRST,LAST,AGE'>\n"+
" <field name='FIRST'><string>Scott</string><string>Jack</
string></field>\n"+
" <field name='age'><number>27</number><number>69</number></
field>\n"+
" <field name='LAST'><string>Hussey</string><string>Hussey</
string></field>\n"+
" </recordset>\n";
var RE = /^\s*<recordset(?
\s+rowCount='\d+?')|(\s+fieldNames='[A-Za-
z0-9,]+?')){2}\s*>((?:.|\s)+?)<\/recordset>/;
var result = RE.exec(testString);
// From Firebug:
// result[0] = entirety of testString
// result[1] = undefined as above, " rowCount='2'" if I switch the
rowCont and fieldNames attributes
// result[2] = " fieldNames='FIRST,LAST,AGE'"
// result[3] = the string within the recordSet tags
not fond of what I've seen) and so far everything is hunky dory.
Rather than writing a full lexical analyzer, I'm just using RE's to
match the pieces of the WDDX schema that I care about. And everything
works except for the the recordset element. Below is the string I'm
trying to match and expression I'm using. The RE matches and populates
$2 and $3 with the correct captures, but $1 is left undefined. If I
switch the order of the rowCount and fieldNames attributes of the
recordset element, then the RE matches and populates all three
captures correctly. Any ideas?
var testString = " <recordset rowCount='2'
fieldNames='FIRST,LAST,AGE'>\n"+
" <field name='FIRST'><string>Scott</string><string>Jack</
string></field>\n"+
" <field name='age'><number>27</number><number>69</number></
field>\n"+
" <field name='LAST'><string>Hussey</string><string>Hussey</
string></field>\n"+
" </recordset>\n";
var RE = /^\s*<recordset(?
z0-9,]+?')){2}\s*>((?:.|\s)+?)<\/recordset>/;
var result = RE.exec(testString);
// From Firebug:
// result[0] = entirety of testString
// result[1] = undefined as above, " rowCount='2'" if I switch the
rowCont and fieldNames attributes
// result[2] = " fieldNames='FIRST,LAST,AGE'"
// result[3] = the string within the recordSet tags