1 Answer
1

I assume you mean pattern matching for values in general. The special case of string pattern matching (regular expressions) is supported via library functions in pretty much any language.

Pattern matching and type checking policy are independent language "features".
Pattern matching is the process in which values are matched against patterns and successful matches are then bound to variables.
A type system is static or dynamic if type checking is enforced at compile time or run time, respectively.

A language can have either of the four combinations of these two features, for example:

C/C++/Java are statically typed languages that do not support pattern matching.

Haskell/Scala are statically typed languages that do support pattern matching.

Icon is a dynamically typed language that does support pattern matching.

JavaScript is a dynamically typed language that does not support pattern matching.

Tangentially, I find it very interesting that pattern matching can actually be used as a foundation for computation. You can search for work on pattern calculus, by Barry Jay if this piques your curiosity.

If we want to add "pattern matching" feature to c/c++/java/javascript, is it possible in theory?
–
FreewindJun 22 '14 at 13:02

In theory, yes. But things tend to escalate quickly. Just think about what you would need to do if you wanted to add pattern matching and keep static type checking (hint: you need to somehow augment the compilation process).
–
EranJun 22 '14 at 13:36

@om-nom-nom I didn't mean this as strictly theoretical. Just meant to emphasize that this is not trivial to implement. Anything is possible when your language is Turing complete. I'm on a horse.
–
EranJun 22 '14 at 16:14