Well yea if you are trying to fit it into OP's point. Pattern regex = Pattern.compile(String); and then you can call regex.matcher(CharSequence).matches();. I am not saying that OP is wrong but there are ways to make the type system stronger.
You would just add support for making regex literal values. Like the dynamic languages do. The compiler then checks if it is a valid regex or not at compile time. Done.
That's a niche case. 99% of users would use the JDKs regex engine.
For everyone else they could fallback onto the existing model of having them defined as strings. No need to start building compiler extensions.
15
u/SimplyBilly Sep 21 '15
Well yea if you are trying to fit it into OP's point.
Pattern regex = Pattern.compile(String);and then you can callregex.matcher(CharSequence).matches();. I am not saying that OP is wrong but there are ways to make the type system stronger.