Skip to content

Commit d4e6cc8

Browse files
committed
auto detect message seperator
Using the string between field 8= and 35= as seperator. Allow multiple char seperators.
1 parent 12f2df7 commit d4e6cc8

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/scripts/app/FixParser.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,31 @@ define(
1818
return parseFloat(beginStr.substr("FIX.".length));
1919
};
2020

21+
var splitFields = function(str) {
22+
var result = str.match(/[^0-9a-zA-Z:\s]*8=FIX(?:[^=]{0,20}?)\D9=\d+(?<delim>.*?\D)35=/);
23+
if (result !== null) {
24+
return str.split(result.groups.delim);
25+
} else
26+
{
27+
return str.split(/\||;|\x001|\[SOH\]|<SOH>|\^A/);
28+
}
29+
};
30+
2131
FixParser.prototype.parse = function(str)
2232
{
2333
// Create a sequence of fields
24-
var regex = /([0-9]+)=([^|;\001]*)/g,
34+
var regex = /([0-9]+)=(.*)/,
2535
fields = [], result;
2636

2737
var fixVersion = 'unknown';
2838

29-
while (result = regex.exec(str)) {
39+
var splits = splitFields(str);
40+
for (var i=0; i<splits.length; ++i) {
41+
// cut the fields by separators before extracting field id and value
42+
result = splits[i].match(regex);
43+
if (!result)
44+
continue;
45+
3046
var fieldId = parseInt(result[1]),
3147
value = result[2],
3248
field = data.fieldById[fieldId],

0 commit comments

Comments
 (0)