Parsing a string and counting characters.
String Example: type1=12345678901234567890111&type2=3.0.00&type3=1234567811
From reading the user guide it looks like I can use the aqString.ListSeparator to define the & as use the delimiter and then I could the aqString.GetLength to validate the length of the string.
I'd like to do this using a keyword test if possible also.
However what I would like to do is something like the following,
Validate type1 is 23 characters long after the equals symbol
Validate type2 is 6 characters long after the equals symbol
Validate type3 is 10 characters long after the equal symbol
My issue here is that I don't want to count the characters that make up the title, such as type3= would add 6 addational characters to my validation. Is there a way for me to work around this?
Thanks,
Helen's reply got me thinking... Could we just use the powers of JavaScript directly?
function test() { var str = "type1=12345678901234567890111&type2=3.0.00&type3=1234567811"; var strarr = str.split('&'); for (var i = 0; i < strarr.length; i++) { var typearr = strarr[i].split('='); Log.Message(strarr[i]); switch (typearr[0]) { case 'type1': Log.Message("TYPE1: length = " + typearr[1].length); break; case 'type2': Log.Message("TYPE2: length = " + typearr[1].length); break; case 'type3': Log.Message("TYPE3: length = " + typearr[1].length); break; default: Log.Message("unrecognized type"); break; } } }
produces