Having been there and got the scars, please DON'T try to use a regex to parse edifact messages. In general, they are not "regular" in the sense used in "regular expression". If nothing else, the majority of regex variants will only return you the LAST instance of text matched in a match group where typically you want ALL instances.
I have written a parser that accepts an edifact message and provides the details of each message - it is MUCH easier to use, manage and maintain.
(The code I wrote uses an old and fairly on-standard langauge. I would strongly suggest that you use YACC or LEX etc to create a suitable parser. You will be better off in the long run.)
As for the question about detecting odd or even counts of a character, something like (untested)
(xx)*(x)?
will let you know if there is an odd or even number of "x" characters. The first match group will match all even instances and the second any remaining instance that makes the overall count odd. However, this also allows there to be 0 instances that can also be worked around if necessary. Ther are probably many other ways...
Susan