Jump to content

Basic question: How to add a second step to a workflow? (I want to replace /n with | and then trim whitespace)


Recommended Posts

Posted

Trying to build my own workflow, and I know it's pretty basic.

 

I want to:

  1. copy some text
  2. replace all new lines or carriage returns with a certain character, for example | or /
  3. THEN I want to trim excess white space (leaving one space) from the previous output.
  4. and finally, Copy to Clipboard

 

I have it working the way I want, except for step 3--I'm not sure how to add in that step.

 

Here's what I have in step 2:

  • Hotkey > Replace (regext) \n+ with / > Copy to Clipboard

 

I tried adding a step after step 2 to trim whitespace (including Transform), but I think I'm missing something.

 

The second image shows what I tried.

 

What do I add after step 2 to trim whitespace?

 

Thanks!

alfred-workflow.png

alfred-workflow-2.png

Posted

It’s impossible to tell what you’ve done from screenshots alone. Please post your Workflow somewhere so we’re able to take a proper look.

Posted

Is this what you wanted it to do? 

Take a block of text with multiple spaces in it and return a single line with \\ replacing newlines and a single space replacing any double or more spaces?

eg:

input:

This is  Some   test so lets
see   how this  goes  with seeing if this   does anything
 

output:

This is Some test so lets // see how this goes with seeing if this does anything

 

This is what I added to get the above result and I also changed your snippet trigger to a keyword for testing.

1290785345_2021-09-05at5_17pm.png.bf767814f8803280a731123691236617.png

 

Posted
4 hours ago, Sucesso said:

Thanks! I'm trying this, but something's not working. I'll post back when I test it some more.

 

Check which whitespace is in your input. It might be some exotic Unicode that doesn't match the regex above.

Posted
6 hours ago, Pearcen said:

@Sucesso Download my version from https://github.com/pearcenuk/Alfred-public/raw/main/_Paste without newlines.alfredworkflow and see if that works as it does for me.

Things I've updated I've coloured red and left comments

That's perfect! Not sure what's different; I thought mine was the same.

Does it make a difference that your final step is dragged down and lower? Versus mine, which was straight across? I assumed it didn't make a difference. Never mind, I just tested it; it doesn't make a difference. I'm assuming you dragged it down to fit in the window so that I wouldn't get confused.

 

 

alfred-pearcen.png

alfred-sucesso.png

Posted
5 hours ago, Sucesso said:

That's perfect! Not sure what's different; I thought mine was the same.

Does it make a difference that your final step is dragged down and lower? Versus mine, which was straight across? I assumed it didn't make a difference. Never mind, I just tested it; it doesn't make a difference. I'm assuming you dragged it down to fit in the window so that I wouldn't get confused.

 

 

alfred-pearcen.png

alfred-sucesso.png

Extra mile. hehehe nah, just really got into Alfred the last year and thought if I can help then why not.

 

It makes no difference how it laid out at all. I just put it there and coloured it to make it obvious what I had done.

 

Glad it is working for you and good luck and enjoy Alfred and all it has to offer. 

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...