You should probably give us some more rules, like for example, will the N= tags always be in order?
In the example you give: 8=FIX.4.29=040435=8
I don't see any way to differentiate between 9= and 29= (unless there is a rule that says a value can never end in a '.'). Similarly, the last token could be:
40435=8
or 0435=8
or 435=8
or 35=8
or 5=8
You might want to give us some more rules or find a way to preformat or delimit the input string, unless your tag array is guaranteed to clear up this ambiguity.
No good deed goes unpunished. -- (attributed to) Oscar Wilde