Matthew Lancellotti Posted October 29, 2014 Share Posted October 29, 2014 (edited) Perform a search and replace on copied text, and save regexs for future use. Download: http://code.instructorium.com/downloads/Regex.alfredworkflow Please visit http://code.instructorium.com/regex for more information. (also on Packal: http://www.packal.org/workflow/regex ) A summary is below: Commands you can use: 1. Any regular expression (no keyword necessary, Perl-style) "s/this/that/msg" "s@\$(\d+)\.(\d{2})@$1 dollars and $2 cents@g", etc. 2. Follow your regular expression with " save as " and then a name in order to save it for future use. "s&this&that&xg save as mythisthat", etc. 3. Use the "regex" keyword followed by the name you saved it under to execute a saved regex. "regex mythisthat", etc. As far as I know, it works on all versions of Alfred 2 and all versions of OS X. Your custom workflows are saved under ~/Library/Application Support/Alfred 2/workflows/com.verykiwi.regex/RegexSequences.pl. You can delete the com.verykiwi.regex folder after uninstall. Feel free to contact me if you have any issues. Edited November 8, 2014 by Matthew Lancellotti cands 1 Link to comment
Matthew Lancellotti Posted November 8, 2014 Author Share Posted November 8, 2014 Version 1.5.0 is here. Here are the improvements: A checkmark appears on the icon when your regex is valid (correct syntax). Regex will not execute invalid regexs. It is…awesome. You have full control to do custom regexing by opening the file at ~/Library/Application Support/Alfred 2/Workflow Data/com.verykiwi.com/RegexSequences.pl. Your custom regexs remain even when updating Regex. Quoted regexs (sq) can be saved. cands 1 Link to comment
ohmish Posted November 11, 2014 Share Posted November 11, 2014 This is a very neat and novel idea! Recently I’ve been trying to find a good way to do find-and-replace in Chrome, but I didn’t find the Chrome extensions to be very flexible, especially when I wanted to do find-and-replace on text selections. I love this workflow because it’s like a one-size-fits-all: not only is it a good tool for Chrome, but it's also good for any Mac application since I can access Alfred from anywhere! I guess the only downside is that it requires the clipboard, but that isn’t a big deal for me since I have Alfred’s Clipboard History configured as well. If I may suggest, would it be possible to support the tr/// operation as well? Thanks so much! Link to comment
Matthew Lancellotti Posted November 15, 2014 Author Share Posted November 15, 2014 @ohmish Thank you very much, I appreciate it. Regex now supports the tr/// operation. Use cases: tr/this/that tr[a-z][A-Z] y[a-z][A-Z]cs etc.. Link to comment
johnjoonso Posted January 28, 2015 Share Posted January 28, 2015 (edited) I thought I understood some regex but I'm confused here, how does one enter the replace string?edit: I see, its the "/" Edited January 28, 2015 by johnjoonso Matthew Lancellotti 1 Link to comment
johnjoonso Posted January 30, 2015 Share Posted January 30, 2015 Really great script! How can I modify the script so that it works on the selected text in whatever app I have open? Matthew Lancellotti 1 Link to comment
Matthew Lancellotti Posted January 5, 2016 Author Share Posted January 5, 2016 Really great script! How can I modify the script so that it works on the selected text in whatever app I have open? @johnjoonso: Sorry I haven't checked this thread in so long. You must COPY the text to your clipboard (typically via Edit > Copy or ⌘C) before running the workflow. Then, when you type your regex and hit enter, the result is automatically pasted. ------ As a bonus, this means you could potentially copy text from one location, then move your cursor to another location, and get the result in the new location. Link to comment
Bhishan Posted May 15, 2018 Share Posted May 15, 2018 How to use this workflow ? In Alfred 3, I tried "regex tr/that/this" It gives error: Could not open your RegexSequences.pl file. Link to comment
TomBenz Posted June 13, 2022 Share Posted June 13, 2022 [22:21:14.156] Logging Started... [22:37:16.866] Logging Stopped. [22:40:08.978] Logging Started... [22:40:13.799] Regex[Script Filter] Queuing argument ' tr/that/this' [22:40:13.841] Regex[Script Filter] Script with argv '(null)' finished [22:40:13.844] ERROR: Regex[Script Filter] Code 2: Can't locate VeryKiwiHelpers.pm in @INC (you may need to install the VeryKiwiHelpers module) (@INC contains: /Library/Perl/5.30/darwin-thread-multi-2level /Library/Perl/5.30 /Network/Library/Perl/5.30/darwin-thread-multi-2level /Network/Library/Perl/5.30 /Library/Perl/Updates/5.30.3 /System/Library/Perl/5.30/darwin-thread-multi-2level /System/Library/Perl/5.30 /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level /System/Library/Perl/Extras/5.30) at -e line 1. BEGIN failed--compilation aborted at -e line 1. Tried to use this regex workflow -- but getting above error message. Can somebody help in resolving this? or suggest alternative 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