-
Notifications
You must be signed in to change notification settings - Fork 34
Regular Expressions
OreCruncher edited this page Dec 15, 2016
·
2 revisions
This information is intended to give you a quick leg up on understanding regular expressions used within the various configuration files found in Dynamic Surroundings. It is by no means exhaustive and barely scratches the surface of what is possible with regular expressions.
(OK, to be honest, I keep forgetting various details about regex and have this information here so I can refresh my memory.)
- The period
.
is a special operator meaning “any character”. The asterisk*
is another operator meaning “zero or more”. So when you see something like “.*swamp” it means “swamp that can have zero or more characters in front of it”. - The plus
+
is another operator. Since some biomes have the+
character in the name to reference it in a regex expression you must escape it by using a couple of backslash characters: “\\+”. - Use
(?i)
to ignore letter case. Example: “(?i)swamp” will match “Swamp” and “swamp”. - To do a
not
style match use(?!)
. Example: “(?!Swamp)” will match any string that is not “Swamp”. - Use
|
to do an OR. Example: “This|That” will match strings “This” or “That”. - Combine the above together to form complex criteria matching. Example: “(?i)(?!.*swamp.*)(.*wet.*|.*smelly.*)” will match any string containing “wet” or “smelly”, but does not include “swamp”. The comparison is made ignoring case.
- More detailed regex information can be found on the Java website.