Regex for GSM 03.38 7bit character set

If your application sends SMS you want to make sure that characters to be sent comply with GSM 03.38 (e.g. 7bit). If you need to validate (user) input for invalid characters you could do that pretty easily with regular expressions. For Java the following regex is ready to use. For other languages you can base […]

Oracle regular expression aka regexp, issues with character class

In most programming languages the regular expression pattern to find the digit ‘1’ surrounded by ‘;’ and other digits would be something like

So, the pseudo character class “; or digit” is matched zero or more times, then the digit 1 is matched followed by zero or more “; or digit”s. A few examples: […]

Regex: match last occurrence

Today, I found myself looking for a regular expression that matches only the last occurrence of a given expression. As I’m still not a regex mastermind I couldn’t come up with it just like that. The key to the solution is a so called “negative lookahead“. A lookahead doesn’t consume characters in the string, but […]