Top "Pattern-matching" questions

Use this tag for questions about testing whether a data structure has a particular shape or contains particular values in certain locations.

Shouldn't "static" patterns always be static?

I just found a bug in some code I didn't write and I'm a bit surprised: Pattern pattern = Pattern.compile("\\…

java regex static pattern-matching
Scala: Pattern matching when one of two items meets some condition

I'm often writing code that compares two objects and produces a value based on whether they are the same, or …

scala pattern-matching extractor
grok filter (regex) to extract string within square brackets

My application log entries are given below: 2015-06-24 14:03:16.7288 Sent request message [649b85fa-bfa0-4cb4-8c38-1aeacd1…

regex pattern-matching logstash-grok square-bracket
How is pattern matching in Scala implemented at the bytecode level?

How is pattern matching in Scala implemented at the bytecode level? Is it like a series of if (x instanceof …

performance scala pattern-matching bytecode
Cut string after first occurrence of a character

I have strings like 'keepme:cutme' or 'string-without-separator' which should become respectively 'keepme' and 'string-without-separator'. Can this be done in …

sql string postgresql pattern-matching delimiter
Match a phrase ending in a prefix with full text search

I'm looking for a way to emulate something like SELECT * FROM table WHERE attr LIKE '%text%' using a …

postgresql full-text-search pattern-matching tsvector
Haskell record pattern matching

I'm looking for a way to simplify function patterns when the actual data is not required: data X = A | B …

haskell pattern-matching record algebraic-data-types
Matching tuples in Prolog

Why does Prolog match (X, Xs) with a tuple containing more elements? An example: test2((X, Xs)) :- write(X), …

prolog tuples pattern-matching operators associativity
Scala wont pattern match with java.lang.String and Case Class

Hello fellow Scala Programmers I have been working with Scala for some month now, however I have a problem with …

scala types pattern-matching case-class
In Scala, why is NaN not being picked up by pattern matching?

My method is as follows def myMethod(myDouble: Double): Double = myDouble match { case Double.NaN => ... case _ => ... } The IntelliJ …

scala pattern-matching ieee-754 nan