Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Regex Test Function: *OR* syntax

if(/categories/.test(url)) {  ... }  

I'm using the above code to check whether url contains the string "categories". What is the syntax for checking to see if url container the string "categories" OR "character"?

Thanks!

like image 444
HandiworkNYC.com Avatar asked Jul 11 '26 10:07

HandiworkNYC.com


1 Answers

The vertical pipe | denotes "or" in regular expressions

if(/categories|character/.test(url)) {  ... }  
like image 195
Adam Rackis Avatar answered Jul 14 '26 01:07

Adam Rackis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!