Jump to content

Workflow to replace substring from the copied text


Recommended Posts

 

 

I was trying to write an Alfred workflow to replace a single letter/number (or substring) from the copied text.

 

Here is what I have done:

 

query=$1
old_new=($query)

old=${old_new[0]}
new=${old_new[1]}

copied=$(pbpaste)


changed=${copied/$old/$new}


echo -n $changed

 

Here is the link to my workflow in github:  https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/replace.alfredworkflow?raw=true

 

But,  this workflow is not working for MULTI-LINE .

 

 

How to fix the workflow?

 

Example test

==========

s = 'hello'

print(s[0])

 

After running the command   "replace 0 1"

 

I would like to have:

    

s = 'hello'

print(s[1])

 

 

 

 

 

Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...