Have a shortcut that loops through a bunch of tax and I want to check if each line contains a string and if it does remove it. Basically, think of it as a pipe to grep -v.
I’ve trying to replace .string.\n with nothing, or with “” but this doesn’t work. If I leave off the \n I can strip the line, but it leaves a blank line or a line containing “”.
Because there isn’t one and I’m dumb for answering without testing/looking myself. My bad. I’ll stop being lazy and spin up a similar example and test on my end.
Are you sure you only have one line break and not a line break and a carriage return? \n\r
Nope, not sure, it’s text built in a repeat item that gets names and birthdates from my contacts. If I add \n or \r or \n\r to the end of the regex it dos not match
If I add $ to the end, it martches but leaves a blank line. If I leave off the $ it matches and leaves a blank line.
Also, you may wish to consider what happens for the last line. If the last line contains 1604, it won’t match as there is no new line to match against.
But, the earlier screenshot shows a repeat loop, not a piece of text being passed in. The referenced birthday shortcut example from another thread (that I created) had loops, but it would seem that this sort of exclusion would be applied to the final result. Not to each contact … as the inferred text from a contact would only coerce the name and not the birthday.
Perhaps you could capture your input on one of the loop iterations, place a sanitised version in a text action, run the replace against that, and demonstrate the effect you are getting?
That is a good point. I’d thought it’d be better to strip them out inside the loop, but obviously that’s not necessary and I’m not sure why I thought it was.
Moving the match outside of the repeat works fine.