Mastering Regex: Extract Numbers from URLs on Make.com
Have you ever found yourself in a situation where you needed to extract a specific number from a URL using regex, but your solution just didn't seem to work in your environment? Well, you're not alone. This is a common challenge faced by many users, especially when working with platforms like Make.com.
Understanding the Problem
Let's consider a scenario where you have a URL like this: https://app.hubspot.com/contacts/1234567/ticket/1871234567. Your task is to extract the number after /ticket/ using regex. You might try something like /\/ticket\/([0-9]+)/, which works perfectly in a simulator like regex101.com, but not in Make.com. So, what's going wrong?
The Solution
Here's the thing: if you're only matching the number at the end of that single line, you could use this regex pattern: \/ticket\/(?
This pattern uses a named capture group (?
Troubleshooting Tips
If you're still having trouble, make sure you're using the correct scenario match pattern in Make.com. Also, remember that regex can be tricky, and what works in one environment might not work in another. It's always a good idea to test your regex patterns in the environment where they'll be used.
Conclusion
Extracting specific parts of a string using regex can be a bit challenging, especially when switching between different platforms. However, with a bit of patience and practice, you can master it. Remember, the key is to understand the problem, find the right solution, and troubleshoot any issues that arise. Happy coding!
You do have further questions?
Ask your question via E-Mail: Richard@make-app.de
Book a paid Support & Consulting Session
New Make.com user? Sign up through this Affiliate Link to receive 10.000 operations for FREE.