Kartikeyan
Kartikeyan

Reputation: 15

How can I improve this regex?

I am trying to write regex to check domain and path after it for some context value path. I wrote this regex which works. Is there any simple version for this without using or?

  ^/(creditcards|creditcards/.*)?$

    To match:    
    /    
    /creditcards    
    /creditcards/something

Upvotes: 0

Views: 21

Answers (1)

JosefScript
JosefScript

Reputation: 600

Try this:

^/(creditcards(/.*)?)?$

Upvotes: 1

Related Questions