'Regex to exclude URL with special configuration
I want to exclude a url with this configuration https://subdomain.example.com/y22la7hv from a string.
I'm trying to do this with the following regex but is not working: https://subdomain\.example\.com/([a-zA-Z]+([0-9]+[a-zA-Z]+)+)
Where am I failing?
Solution 1:[1]
Here it is after lot's of trying and error. Enjoy!
$str = 'https://subdomain.example.com/y22la7hv';
$pattern = '/https:\/\/subdomain\.example\.com\/([a-zA-Z]+([0-9]+[a-zA-Z]+)+)/i';
$exclude_rgx = preg_replace($pattern, '', $str);
Solution 2:[2]
You miss one backslash ("\"), just after ".com"
\.example\.com\/([a-zA-Z]+([0-9]+[a-zA-Z]+)+)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bpy |
| Solution 2 |
