A modifier is something that will change the behaviour of the pattern matching in some way. Usually when you see the pattern encapsulated inside slashes, the modifiers will follow at the end. In some programming languages the function used for Regular Expressions will instead put these as an optional parameter. The two most commonly used modifiers are g and i which will match globally, and perform a case insensitive search respectively.
- g
- Perform a global match for the patterm - will return multiple instances if found
- i
- Case insensitive matching for the given pattern
- x
- Pattern may contain spaces and comments
- s
- Read the input string as single line when matching the pattern
- m
- Allowing matching over multiple lines
- e
- Evaluate replacement such that if a string is replaced then the result is then what goes through the replacement
- U
- Inverts the "greediness" of the patterns so they are not greedy by default













