Skip navigation
Currently Being Moderated

Using a GREP style to find any number not starting with a 0 (zero)

Aug 26, 2013 12:52 PM

I have cobbled together a few GREPs that find numbers after commas, periods, and quotes and applies a superscript character style. Most of the time it works very well except in cases like 1,000 or 30,000 in which case the zeros after the comma ends up being superscript.


I'm not sure what to do to set something up so those situations are missed or left alone. I barely understand what is going on with what I have put together from various examples I found.


Here are the expressions I am using.









Is this even possible and if so how?


Thanks for any help anyone can give.

  • Currently Being Moderated
    Aug 26, 2013 2:09 PM   in reply to StevenDayton

    I'm not sure whether this is what you specifically want (I guess you're trying to manually format footnote references), but try this pattern:







    (plus your formatting of choice)


    The above example search for a non-digit character (\D), followed by comma or period or quote, followed by any number of digits (\d+). It affects only the last part (the sequence of digits), in which you can apply a character style (recommended) or just the superscript format.


    In my tests, it worked in strings like:


    lorem ipsum,4

    lorem ipsum"12


    and ignored cases like





    Maybe it still needs some tweakings to fully work as you need.

    Mark as:
  • Currently Being Moderated
    Aug 26, 2013 2:23 PM   in reply to StevenDayton

    Well, you probably noticed that I misread your post and thought you were looking for a GREP pattern for the Search/Replace function, not for a GREP style.


    But fortunately my pattern works in a GREP style too. Just choose your desired character style in the "Apply Style:" field and use the above GREP pattern in the "To Text:" field.


    Sorry about the confusion :-)

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points