Find/Replace assistance
Learn / Forums / InDesign User Groups / Find/Replace assistance
- This topic has 8 replies, 3 voices, and was last updated 4 years, 3 months ago by Brian Iannantuono.
-
AuthorPosts
-
-
March 13, 2019 at 4:49 pm #114936Brian IannantuonoMember
Object is to copy/paste credit card statement entries into InDesign, insert 2 tabs, export as text and import into .xcel and sort by vendor and then total the columns.
Below are 3 lines of many of credit card statements. From this forum I’ve learned how to switch the dates at the beginning of the line and the space to a tab. Now I need to know how to change the last space in the end of the line to a tab. I’m stumped. Any assistance is appreciated.
12/08 4OVER 818-246-1170 CA 11.00
12/07 PRESSCENTRIC 888-8504497 NV 79.99
12/09 4OVER 818-246-1170 CA 11.00 -
March 13, 2019 at 5:11 pm #114950Erica GametParticipant
I can’t get it to work right for the final line, so you may have to do a forced return after the very last line (it’s odd because in the sample above, it finds three instances, but messes up the last line). Then do:
Find: (.)(\r)
Replace with: $1\t$2That gives you 11.00[tab character here][para return here]
If you want it to all end up on the same line, then replace with: $1\t only -
March 13, 2019 at 5:17 pm #114953Aaron TroiaParticipant
Hey Brian,
This will change the last space in each line (between the state and the price)
Find: \s([^ ]+)$ Change: \t$1
or if you want to add a tab after the price on each line
Find: (\d)$
Change: $1\t
wasnt sure where you wanted the space.
Aaron
-
March 14, 2019 at 8:20 am #114965Brian IannantuonoMember
Thanks to both Erica & Aaron for your assistance. Aaron’s worked beautifully. Aaron, can you please explain what that code actually means. I’d like to learn the logic behind it. This will save me so much time going forward on itemizing the credit card statement. It’s amazing that in 2019 the cc companies don’t give you the tools to itemize by vendor but it’s what it is. Thanks again!
-
March 15, 2019 at 9:53 am #114974Aaron TroiaParticipant
Of course, I’m glad it worked! Not sure which one you’re referring to so I will break down both.
The first one I’m telling GREP Find/Change to find everything between the end of the line that is not a space (
[^ ]+
) and the last space (\s
) before the end of the line ($
). Once it finds that space I am telling it to then change that space to a tab (\t
) and then replacing the same content that was after the space ($1
) to be after the tab. I dont use the greedy negated character class ([^ ]+
) very often, but it comes in handy at times when you want to be very specific that GREP, in this case, find everything that is not whatever is within the square brackets.Find:
\s([^ ]+)$
\s
– find a space
([^ ]+)
– capture group (everything within parenthesis) to “find everything that is not a space.” ([^ ]+
) which is a negated character class (anything between the square brackets) with a carrot (^
) saying that this is a negative character class, and a literal space. The+
is making it greedy, or the “find everything” part.
$
– end of lineChange:
\t$1
\t
– tab
$1
– variable to denote the capture group in FindThe second one is similar to the first, but since you just had numbers/digits at the end of each line I am telling GREP Find/Change to find the last digit (
\d
) at the end of each line ($
) and replace the digit in the same place it was before with the capture group variable ($1
) and then adding one tab after it (\t
).Find:
(\d)$
\d
– any one digit
$
– end of the lineChange:
$1\t
$1
– variable to denote the capture group in Find
\t
– tabHope that explanation helps! Let me know if you have any questions on any of it.
-
March 18, 2019 at 10:22 am #115016Brian IannantuonoMember
Good day Aaron. That’s a great detailed explanation. I appreciate your assistance tremendously and the explanation is priceless. I wish I could repay the favor. I was a Quark user from 1990 til approx 2000 and have been working with InDesign since it’s creation. It’s impressive what can be done within this program. Thanks!
-
December 12, 2019 at 3:50 pm #14323462Brian IannantuonoMember
Hi Aaron. I’m stuck trying to accomplish what we discussed in March.
The notes that I made in the margin of last years file isn’t accomplishing the goal of replacing first & last space of line with a tab.
My notes:
Find — Change: GREPFind what:
(\d\d/d\d\d\sChange to:
$1\t(Changes first space in string to tab)
Find what:
\s([^ ]+)$
\t$1
———————–
When trying the above script it gives me “cannot find match” right off the bat, I believed I had the key to changing the first space to a tab (perhaps is expired like milk:).
Sorry to be a pain, but if you could list the string to make it go, I’d appreciate it.12/07 COX PHOENIX COMM SERV 800-234-3993 AZ167.98
12/07 4OVER 818-246-1170 CA 22.00
12/07 SIGNS365.COM 800-265-8830 MI 17.41
12/10 PRINTGEAR SPORTSWEAR DIS 8037917763 SC 199.78 -
December 12, 2019 at 4:15 pm #14323461Aaron TroiaParticipant
Hey Brian,
No problem. For the first space in the line I would do like what you did:
Find:
(\d\d/\d\d)\s
Replace:$1\t
The last space GREP should work, (make sure you’re in GREP not Text, I just got the “Cannot Find Match” error pop up on me because I accidentally had it in Text) but I can give an alternate,
the original, which is finding anything between the end of the line and the last space in the line:
Find: `\s([^ ])$
Replace:\t$1
an alternate, being explicit about the digits and period:
Find :\s(\d+\.\d+)$
Replace:\t$1
Let me know if that works for you or if it’s still giving you issues.
-
December 13, 2019 at 8:26 am #14323457Brian IannantuonoMember
Hi Aaron.
I believe I had a slash incorrect in the first part of the script. That part is now perfect!
When changing the last space, it does insert the tab before the $ amount. The only rub is if the charge is over 999.99 (or 4 digits then decimal), it doesn’t perform the “remove space add tab”, it just deletes the space. It’s not a big deal, I have to give the thing a once over anyway, there may be 25 entries where the charge is that large.
I appreciate your assistance immensely. This will easily save me 12 hours of going thru statements and summarizing them manually not to mention eliminating the error rate doing it manually with a calculator.
Thanks Aaron!
-
-
AuthorPosts
- You must be logged in to reply to this topic.