문제

I need to filter urls based on user input, but the filter must not be case sensitive. For example my user wants to filter for files ending with Sewer.pdf. If I create a regex like this:

+Sewer\.pdf$ 

works fine, however user may have entered SEWER.PDF and it will skip the file. My solution was to create a rule like this:

+[Ss][Ee][Ww][Ee][Rr]\.[Pp][Dd][Ff]

However it looks like there should be something like the /i in the regex that would make it much easier.

Does anyone know how to do it in a better way?

도움이 되었습니까?

해결책

You could try adding the case insensitive flag (?i):

.*(?i)SEWER\.PDF 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top