简体   繁体   中英

How to check for optional URL params using regex?

I've been trying to use regex to determine if the current URL matches to either http://test.com or http://test.com/page/[0-9]+

I've been looking at countless of tutorials but couldn't find any that tackled anything even remotely such as this. I've tried just about everything but I'm just too inexperienced with regex to get it going.

Thank you for your help and I hope you could point me in the right direction.

你可以试试

"http://test\.com(?:/page/[0-9]+)?"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM