Fazio8 Posted June 27, 2023 Posted June 27, 2023 Hello, I'm looking on a workflow to copy a specific string (12 character/digits) with no symbols in it, transform it in the same string but adding a colon symbol ( : ) every 2 characters. Is it possible via workflow or via Text Expander/Replace utility? I have no clue on how to start! Thank you!
zeitlings Posted June 27, 2023 Posted June 27, 2023 I'm not entirely sure what your desired result looks like. An example would be helpful. I assume you are looking for this: h3llog00dbye -> h3:ll:og:00:db:ye You can do that with RegEx: (.{2})(?!\b) Replacing the captured groups with $1: You can use the "Replace" utility for that. See also: https://regex101.com/r/tZMJDZ/1
Fazio8 Posted June 28, 2023 Author Posted June 28, 2023 19 hours ago, zeitlings said: I'm not entirely sure what your desired result looks like. An example would be helpful. I assume you are looking for this: h3llog00dbye -> h3:ll:og:00:db:ye You can do that with RegEx: (.{2})(?!\b) Replacing the captured groups with $1: You can use the "Replace" utility for that. See also: https://regex101.com/r/tZMJDZ/1 Hello! Thank you! Is it possible to filter this for only 12-digits/chars elements in the current clipboard?
zeitlings Posted June 28, 2023 Posted June 28, 2023 Hey, sure. It is still not clear what you want to do exactly, though. I assume you are looking for a solution that simply doesn't trigger if the input is not 12 characters long. Here's a zsh solution you can adjust to your use case: https://transfer.sh/J5DLx9TQWs/h3llog00dbye.alfredworkflow if [[ $(echo -n $1 | wc -c) -eq 12 ]]; then echo -n "$1" | sed -E 's/../&:/g; s/:$//' fi
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