Search code examples
rubyregexcase-insensitive

How do i do a case insensitive search based on this url


Here is the url i am trying to match

/anyfirsturl/apPles/1

the first part can be anything

/^\/[\w]*\/apples\i

This regular expression doesnt match anything so far

I want it so the user can enter in APPLES or APPles or any way or for and any number after


Solution

  • I think this should work:

    /^\/[\w]*\/(apples)\/\d+$/i
    

    the i option will do a case insensitive search, and should match all of those permutations.