Nice code Alan
One thing I would add would be that vl-string-subst only replaces the first occurrence of the string to be replaced, hence I would usually use a function like:
(defun StringSubst ( new old str )
;; © Lee Mac ~ 23.05.10
(
(lambda ( i / nl ) (setq nl (strlen new))
(while
(and (< i (strlen str))
(setq i (vl-string-search old str i))
(setq str (vl-string-subst new old str i) i (+ i nl))
)
)
str
)
0
)
)
In place of it
Well, ... Perhaps it is another episode of 'Hangman's Luck', but I don't think this is necessarily the case for this purpose.
I went and re-wrote Alan's code (trying to learn it) using my own variables and such (minor changes, but I'm grasping the concept of his format - very nice by the way), and ran the program. The program cleaned up the ASCii fractions nicely. So out of curiosity, I went and placed several ASCii fractions into one string of text and ran the code again. It cleaned up every one of them. So I then pulled his code from here and ran it as-is, and it cleaned up the line of text with several ASCii fractions in it.
Now from the help file we read:
Note that the search is case-sensitive, and that vl-string-subst substitutes only the first occurrence it finds of the string.
So Lee is correct, it will only substitute the first occurance.
But then why is Alan's first code post above (without the update) able to clean up multiple occurances ?? At least on my machine it's cleaning up multiple occurances within the same line of text.