Created
January 26, 2016 02:48
-
-
Save DexterHaslem/53a7944eb8655769806b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testStr = "8=FIX4.2.\x019=65\x0135=A\x0149=S\x0156=C\x0134=177\x0152=20160125-18:30:55\x0198=0\x01108=30\x0110=065\x01" | |
soh = Char(0x01) | |
function fix_parse_split(str) | |
ret = [] | |
for chunk in split(testStr, soh) | |
if length(chunk) > 0 | |
push!(ret, chunk) | |
end | |
end | |
return ret | |
end | |
function fix_parse_idx(str) | |
ret = [] | |
prev_idx = 1 | |
for idx in 1 : length(str) | |
# beware julia indexing starts at 1!! | |
if str[idx] == soh && idx > 1 | |
# we want to match parse_split so dont include SOH | |
chunk = str[prev_idx:idx - 1] | |
if length(chunk) > 0 | |
push!(ret, chunk) | |
end | |
prev_idx = idx + 1 | |
end | |
end | |
return ret; | |
end | |
assert(parse_idx(testStr) == parse_split(testStr)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment