Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

User Image
Eric Leung75845
4 discussion posts
Hi, any tips on how to detect when copying a phone number and then remove all special characters from the clipboard? Thank!
May 17, 2023  • #1
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Hi Eric,

We have a script in our repository called "Replace Special Character with Hyphens" that you can download (ClipboardFusion Settings > Macros > Download Premade Macros) and modify. You can add/remove any special characters you want it to modify, and attach a key combination to manually run it when you copy a phone number.

Hope that helps!
May 17, 2023  • #2
User Image
Eric Leung75845
4 discussion posts
Is it possible to not activate by hotkey? But always trigger automatically whenever I copy a text, it will remove Hyphens?
May 17, 2023  • #3
User Image
C# Clouseau
85 discussion posts
You can run a macro from a trigger. This feature is not available in the free version. So with ctrl-C or double ctrl-C a trigger is activated and in the trigger you can specify/include the macro that replaces the unwanted characters.
May 18, 2023  • #4
User Image
C# Clouseau
85 discussion posts
and if it is only about hyphens to be replaced you can use a trigger only on (double) ctrl-C. In the trigger settings you can specify to replace a hyphen by nothing or a space or whatever.
May 18, 2023  • #5
User Image
C# Clouseau
85 discussion posts
and visit this discussion: https://www.clipboardfusion.com/Discussions/View/run-trigger-on-double-copy-not-working/?ID=03925d69-ad49-4ec4-a521-604e75d8370b
May 18, 2023 (modified May 18, 2023)  • #6
User Image
Eric Leung75845
4 discussion posts
Thanks for all the info. I don't mind buying the Pro version as long as I can make it work.

The problem is that I only want to remove all special characters IF the clipboard content matchs a phone number format.

1. When ctrl-c is pressed
2. Clipboardfusion should check the clipboard content
3. If the content matches a phone number format (e.g. xxx-xxx-xxxx)
4. Remove all non-numeric characters, and update the clipboard content
5. So when I paste it, the phone number is cleaned

Is there any example macro code that I can try? I guess it is only a few lines of code, but I don't know how to write it.
May 18, 2023  • #7
User Image
C# Clouseau
85 discussion posts
What you want can only be done by c# coding, thus a macro. The macro looks at the/your copied string. If only digits and/ or hyphens it has to remove the hyphens otherwise do nothing. Yes a few lines of code 😁, but I do not think it is in the library yet.
May 18, 2023  • #8
Keith Lammers (BFS)'s profile on WallpaperFusion.com
You can do this with just a Trigger rule that uses a Regex to look for ###-###-#### and then have the Trigger do a text replace on the hyphen. I've attached a screenshot for reference.

The RegEx is
(\d{3}-){2}\d{4}


This part
(\d{3}-){2}
says look for 3 digits followed by a hyphen, and do it twice.
This part
\d{4} says look for 4 digits


Hope that helps!
• Attachment: 10digitphonenumberregex.jpg [112,396 bytes]
10digitphonenumberregex.jpg
10digitphonenumberregex.jpg
May 18, 2023  • #9
User Image
Eric Leung75845
4 discussion posts
Thank you very much! It works perfectly!

Quote:
You can do this with just a Trigger rule that uses a Regex to look for ###-###-#### and then have the Trigger do a text replace on the hyphen. I've attached a screenshot for reference.

The RegEx is
(\d{3}-){2}\d{4}


This part
(\d{3}-){2}
says look for 3 digits followed by a hyphen, and do it twice.
This part
\d{4} says look for 4 digits


Hope that helps!
May 19, 2023  • #10
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)