Bottacco Posted September 24, 2019 Share Posted September 24, 2019 I am trying to create a simple workflow to copy a selected row in Excel and place it on the clipboard after changing the tab character that separates fields in a return character. I am trying to use a conversion with regex of \t to \n but it is not working. Any ideas? Link to comment
deanishe Posted September 24, 2019 Share Posted September 24, 2019 Hi @Bottacco, welcome to the forum. For some reason, Alfred doesn't understand \n and the like in its Replace utility. You'll have to use a Run Script instead. This is Python: import sys sys.stdout.write(sys.argv[1].replace('\t', '\n')) Bottacco 1 Link to comment
Bottacco Posted September 24, 2019 Author Share Posted September 24, 2019 Thank you very much for your help @deanishe. I have found an old comment by @Andrew stating that Alfred uses NSRegularExpression for regex search and replace and that \n in the substitution field is not recognized because the \ character is taken as a literal. The solution offered by @Andrew is to use Alt+Return instead. I have tried it and it works, but now there is a second problem: once you input Alt+Return in the substitution field there is no way to delete it because it doesn't appear in the field, so I had to delete that element in the workflow and recreate it. The post where Andrew talks about it is here: Link to comment
deanishe Posted September 24, 2019 Share Posted September 24, 2019 8 hours ago, Bottacco said: there is no way to delete it because it doesn't appear in the field, so I had to delete that element in the workflow and recreate it. Doesn't ⌘A and ⌫ work? Bottacco 1 Link to comment
Bottacco Posted September 25, 2019 Author Share Posted September 25, 2019 (edited) You are right. It didn't occur to me to use ⌘A on an empty field. Thank you very much for your help, but I hope that the behavior with regex with normal things like \t and \n becomes standard. Cheers Edited September 25, 2019 by Bottacco Link to comment
deanishe Posted September 25, 2019 Share Posted September 25, 2019 2 hours ago, Bottacco said: It didn't occur to me to use ⌘A on an empty field The field's not empty. Newlines are invisible. 2 hours ago, Bottacco said: I hope that the behavior with regex with normal things like \t and \n becomes standard Yeah. That's pretty much how they work everywhere else, and it's surprising and somewhat frustrating that Alfred doesn't understand things like \n. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now