The following two strings are the result of the expansion of a biblatex citation command:
Unicom Computer Corp. (in re), 13 F.3d 321, 30 Collier Bankr. Cas. 2d 655, 25 Bankr. Ct. Dec. 152 (9th Cir. 1994)
Personal Property Security Act (P.E.I.), R.S.P.E.I. 1988, c. P-3.1
What I want to do is wrap the biblatex citation command in a macro that will replace all dots, with a replacement character determined by the following condition set:
If the character to the right of the dot is not a number, the dot should be removed entirely.
If the character to the right of the dot is a number, and the character to the left of the dot is a number, the dot should be replaced by a dot, that is the dot should be kept in place.
If the character to the right of the dot is a number, and the character to the left of the dot is not a number, the dot should be replaced by a space.
Applying the conditions on the example strings above, the macro should yield the following results:
Unicom Computer Corp (in re), 13 F 3d 321, 30 Collier Bankr Cas 2d 655, 25 Bankr Ct Dec 152 (9th Cir 1994)
Personal Property Security Act (PEI), RSPEI 1988, c P-3.1
It should be noted that the dots in the examples are already in the entries in the bibtex file. The reason that the dots are in there are that certain legal citation styles require the punctuations, whereas others require they are not present, the biblatex style I am writing should have an option to turn punctuation on or off, and it seems way easier to remove dots automatically but to add them automatically.
I have looked into the xstring package, but I was not able to find an appropriate macro in there. Furthermore, I would prefer being able to do that in plain TeX, so that the resulting style can be used without too many dependencies.



l3regexpackage. However, it does require the wholeexpl3bundle, which is a non-trivial dependency. Otherwise, you may be able to approach the problem in several passes. In order to look behind the dots, you will need to have a function to reverse the string of characters. – Bruno Le Floch Oct 20 '11 at 14:48