Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: ejonesWith regular expressions, any punctuation characters tend to do interesting things and they don't work like the wildcard matching you may be more familiar with.
An asterix, *, indicates that whatever in front can be matched to zero or more repetitions of it. So EFP*010 would be matching EFPPPPP010 and EFPP010 and even EF010.
A pipe character is used for an "either or" match. I really don't know what it does the way you have it. and would have to do some studying and testing with it to find out.
If you want an asterix to match an asterix you put a back slash in front of it. This is true for any punctuation characters, and to be safe I always put an asterix in front of all punctuation characters in a regex that I want to match to themselves. For example, if I want to match to the string "EFP*010" the regex I would use is "EFP\*010". And if I want to match to "|EFP*010|" I would use the regex "\|EFP\*010\|". BUT ... (see next paragraph)
In BrainScript we have one more thing to deal with. The backslash has a special meaning. It is used to represent certain characters that aren't easy to represent otherwise. For example, \n is for a line feed, \r is a carriage return, \" is for a double quote that does not indicate the end of the string, and \\ is for a simple single backslash character. SO ... (see next paragraph)
The BrainScript code you would use to match to the string "EFP*010" would look like the following because you need two backslash characters to represent one,, 'list'.regexIsMatchI("EFP\\*010"). And to match "|EFP*010|" you need to do this: 'list'.regexIsMatchI("\\|EFP\\*010\\|").