Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

GREP Styles Help

Return to Member Forum

  • Author
    Posts
    • #1239932
      Stan Cain
      Member

      Hello all, I have some data that I need formatted, they look something like this:
      *0000003*2012* COMPANY NAME 000000000018756 R
      There are THOUSANDS of records.

      I would like to reformat them using multiple GREP styles to this:
      0000003 2012 COMPANY NAME $1.8756
      Manually reformatting these is not an option, any help would be GREATLY Appreciated.

    • #1239959
      Aaron Troia
      Participant

      Hey Stan,

      Unfortunately you cannot add/remove with GREP styling, you can only apply a styles. You would need to GREP the content to match with Find/Change first.

      You could run two GREP searches with Find/Change, the first to format everything but the price,
      Find: ^\*(\d+)\*(\d+)\* ([^0]+)(\d+ R)
      Change: $1 $2 $3$4

      and the second one to convert the number string followed by the R to a price
      Find: 0+(\d)(\d+) R
      Change: $$1.$2

      These should work they were based on the example you gave, but let me know if they need some tweaking. Just to be safe I would run a test with these in a copy of your document first.

      Aaron

    • #1239979
      David Blatner
      Keymaster

      Probably not the most elegant solution, but: you can find:
      ^\*(\d+)\*(\d+)\*+?([\w]+?)+?\d{10}(\d)(\d\d\d\d)R
      replace with
      $1 $2 $3 \$$4.$5

    • #1239999
      Stan Cain
      Member

      Aaron, David, You Guys are AWESOME, I am finally making some headway after more than a week! quick edit, If I need to move the decimal to be in front of the 2 digit cents (EXAMPLE) change FROM 000000000049885 TO $498.85 How do I update $$1.$2

    • #1240009
      Aaron Troia
      Participant

      To change where the decimal is we would probably want to change the Find to similar to what David used in his GREP (its just some adjusting of the parenthesis that he used).

      Find: 0+(\d\d\d)(\d\d) R
      Change: $$1.$2

    • #1240019
      Aaron Troia
      Participant

      Haha David, we were! and our GREPs were pretty similar too, I like how you did everything in one line!

    • #1240029
      Stan Cain
      Member

      Ok, I think I got that section perfect, Thank you Aaron, Now how do I add a convert multiple spaces (It will be different, based on the names on) into a single TAB

    • #1240039
      Aaron Troia
      Participant

      oh good! Im glad that worked!

      To convert multiple spaces you could try,
      Find: +
      Change:

      Watch out though, in some instances will catch both hard and soft returns as well, so only for literal spaces (space bar),

      Find: +
      Change:

    • #1240079
      David Blatner
      Keymaster
    • #1240159
      Stan Cain
      Member

      Your help has been greatly appreciated Aaron, I do notice that when I do the string 0+(\d\d\d)(\d\d) R it misses some of the records, seems like it misses the ones with 9 zeroes before a number EXAMPLE (0000007 COMPANY NAME 000000000870998 R) It passes over all of the records with 9 zeroes.

      So I edited the string to 0+(\d\d\d)(\d\d\d) R and to be replaced with $$1.$2 and run it again to catch the leftovers and it puts the decimal in the wrong location example ( $870.998), need it before the last 2 digits not 3.

    • #1240169
      Stan Cain
      Member

      Thank You David, I have been looking at this morning.

    • #1240179
      Aaron Troia
      Participant

      oh! I see we were just accounting for prices with 5 digits. Lets tweak our Find GREP what we had before to fix that, try this

      Find: 0+(\d+)(\d\d) R
      Change: $$1.$2

      Now it shouldn’t matter the length, it will put the period before the last two numbers.

    • #1240189
      Stan Cain
      Member

      This is working Perfectly David, I will go through and do all the updates and let you know, HUGE THANKS AGAIN.

Viewing 12 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads