GREP Apply strikethrough to Prices only

Learn / Forums / General InDesign Topics / GREP Apply strikethrough to Prices only

Tagged: ,

Viewing 4 reply threads
  • Author
    Posts
    • #100904
      Glen Hart
      Member

      Hi Guys, Hope you can help, I’m fairly new to the GREP’s but am trying to apply a strikethough to any prices in the following formats, but ONLY IF they follow on from the letter PM.

      Example
      PM £X
      PM £X.XX
      PM £XX
      PM £XX.XX

      I have come up with the following which works when i’m just changing the text color but when I apply the strikethrough to the character style it then strikes through to the entire line, in addition it also seems to apply it to other prices elsewhere in the document even though they don’t come after the letters “PM”.

      (?<=[PM]\s)(£\d+)|(£\d+.\d+) this doesn’t work at all but i thought it should
      (?<=[PM]\s)£\d+ without pence (works when adjusting font color)
      (?<=[PM]\s)£\d+.\d+ with pence (works when adjusting font color)

      Thank you in advance and appreciate any help you can offer :).

    • #100907

      Hi Glen, this seems to works fine:
      (?<=PM )£\d+\.?(\d+)*

      (?<=PM ) without square brackets
      £\d+\.?(\d+)* this apply the format to the prices

      Let try it

    • #100909
      Glen Hart
      Member

      Hi Claudio, thank you I really appreciate this.. That works perfectly! Can I ask what the question mark and star do at the end

      “?(\d+)*”

      Is this a wildcard of some sort?

    • #100910

      Of course you can!

      ? and * are relative to the preceding character

      \.? means literal period 0 or 1 time (either case GREP find the match)
      (\d+)*, or better \d* means figure 0 or multiple times

    • #100911
      Glen Hart
      Member

      Thank you very much! Have a lovely day :)

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
>
Notice: We use cookies on our websites to give you a great online experience. If you keep browsing, we'll assume you're ok with this. For more information, see our privacy policy. By closing this banner, you agree to the use of cookies.I AGREENo