Grails/Groovy regular expression- how to use (?i) to make everything case insensitive?
问题 I use the following RegEx: url (blank:false, matches: /^(https?:\/\/)(?:[A-Za-z0-9]+([\-\.][A-Za-z0-9]+)*\.)+[A-Za-z]{2,40}(:[1-9][0-9]{0,4})?(\/\S*)?/) I want to add (?i) to make everything case insensitive. How should I add this? 回答1: I can confirm the (?i) at the beginning of the regex makes it case insensitive. Anyway, if your purpose is to reduce the regex length you can use the groovy dollar slashy string form. It allows you to not escape slashes / (the escape char becomes $ ). In