Sample Header Ad - 728x90

Using regular expression in shortcuts and getting inconsistent behavior

2 votes
1 answer
1559 views
I'm using shortcut to input and append info to a note document. The issue is that I'm trying to escape all the quotes and apostrophes in my inputs, but some might already be escaped so I have to do so selectively. The command I made for this in shortcuts was `Replace (? Hello there it's me, don\\'t escape this one. "One quote" followed by \\"another\\" > > Testing new date format and some escape characters like " and it's Which then becomes > Hello there it\\'s me, don\\'t escape this one. \\"One quote\\" followed by \\"another\\" > > Testing new date format and some escape characters like " and it's So for whatever reason it isn't replacing anything on the second line with the escaped versions. I built this regex over at https://regexr.com/ where it matches all the strings in the input I give so it should work as far as I can tell, and it's not like the negative look behind isn't supported since it works fine in the first line. I also tried adding a separate " ' after the second line to see if it'd get escaped and those ones did, but the ones already in that line didn't. enter image description here enter image description here Can anyone offer an explanation so I can better understand what's going on with the expression I chose and the data I’m feeding it?
Asked by Xavier (21 rep)
Jun 25, 2021, 05:13 AM
Last activity: Mar 2, 2025, 01:04 PM