Rahul Maheshwari
Rahul Maheshwari

Reputation: 13

Regex, filter url ending with and without digit

I have below four URLs, out of which I want to filter only two using regex expression.

/chassis/motherboard/cpu <---- this

/chassis/motherboard/cpu/core0

/chassis/motherboard/cpu0 <---- this

/chassis/motherboard/cpu1/core0

I have tried to play around with ^.*[0-9a-z_].cpu but I'm unable to get the solution.

Upvotes: 1

Views: 96

Answers (1)

anubhava
anubhava

Reputation: 786081

You can use this regex:

^.*/cpu[0-9]*$

This will match any text that ends with /cpu or /cpy<number>

Upvotes: 1

Related Questions