How to pass 'or' condition using regex?

by elise_daugherty , in category: Third Party Scripts , 24 days ago

How to pass 'or' condition using regex?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by daisha , 23 days ago

@elise_daugherty 

To pass an 'or' condition in a regular expression, you can use the pipe symbol | which acts as the OR operator:


For example, if you want to match either the word "apple" or "orange" in a string, you can use the following regex pattern:


apple|orange


This pattern will match either "apple" or "orange" in the input text.