NET languages have the IgnoreCase option. See the section on inline modifiers for juicy details about three additional features (unavailable in Python): turning it on in mid-string, turning it off with (?-i), or applying it only to the content of a non-capture group with (?i:foo)Īpart from the (?i) inline modifier. NET, PCRE (C, PHP, R…), Perl, Python, Java and Ruby (but not JavaScript), you can use the inline modifier (?i), for instance in (?i)cat. Even if I knew all the answers, it would be impossible to include them all in this section: if you use a particular script, you'll need to research how your specific engine handles case-insensitive matching in that script.įor several engines, note that there are two ways of turning on case-insensitive matching: as an inline modifier (?i) or as an option in the regex method or function. These questions are just the tip of the iceberg. ✽ Will i match İ (Turkish capital i) as well as I? ✽ Will ß match ss? No engine seems to do so. the letter a and the grave accent) match À? All engines seem to handle that correctly. Here are some questions you may run into. When you branch out into typographical niceties or other languages and scripts, things are not always so simple. If you want patterns such as Name: + to match in case-insensitive fashion, we need to turn that feature on.Īs long as you stick to the 26 letters of the English alphabet, the definition of upper-case and lower-case is straightforward. ✽ PCRE's Special Start-of-Pattern Modifiersīy default, all major regex engines match in case-sensitive mode. ✽ Multiline ( ^ and $ Match on Every Line): m (except Ruby) ✽ DOTALL (Dot Matches Line Breaks): s (except Ruby and JavaScript) The final section briefly surveys other modifiers, which are usually language-specific.įor easy navigation, here are some jumping points to various sections of the page: Rather than repeatedly explain what they do and the multiple ways to turn them on in every regex flavor, I decided to gather the four common ones ( i, s, m and x) in one place. Regex modifiers turn up at every corner on this site. This is a reference page-don't feel you have to read it as it is rather terse.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |