Skip to content

Instantly share code, notes, and snippets.

@DexterHaslem
Created January 26, 2016 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DexterHaslem/53a7944eb8655769806b to your computer and use it in GitHub Desktop.
Save DexterHaslem/53a7944eb8655769806b to your computer and use it in GitHub Desktop.
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