Insert a zero before a single digit

Insert a zero before a single digit

4

    Aug 20, 2011#1

    Hiya folks,
    Is there a macro available that would insert a zero before all single digits? 1 becomes 01, 9 becomes 09. I've searched these forums for a clue but haven't read anything that would pertain to this. Much help needed.

    6,681583
    Grand MasterGrand Master
    6,681583

      Aug 20, 2011#2

      There is no real need for a macro because this can be done by running a tagged regular expression replace all with any of the 3 regexp engines and using additionally Match Whole Word Only option. This single replace all recorded to a macro:

      Using the UltraEdit engine:
      Top
      UnixReOff
      Find RegExp MatchWord "^([0-9]^)"
      Replace All "0^1"


      Using the Unix engine:
      Top
      UnixReOn
      Find RegExp MatchWord "([0-9])"
      Replace All "0\1"


      Using the Perl engine:
      Top
      PerlReOn
      Find RegExp MatchWord "([0-9])"
      Replace All "0\1"


      With the Perl engine there would be also other possibilities without MatchWord, but there is no reason to make something more difficult than really necessary.

      4

        Aug 21, 2011#3

        Mofi,

        Took awhile to respond but had to figure out what a tagged regular expression was. UE website has an example and the UE program help files has info there, too. Would have still been confused if not for your example. So much to learn about this great program and the concept behind coding and understanding it.

        Thank you for your teachings.