Questions tagged [matching]

For questions related to pattern matching, using character sequences or tree structures. In contrast to pattern recognition, the match described here usually has to be exact.

In contrast to pattern recognition, the match usually has to be exact. The patterns generally have the form of either sequences or tree structures. Uses of pattern matching include outputting the locations (if any) of a pattern within a token sequence, to output some component of the matched pattern, and to substitute the matching pattern with some other token sequence (i.e., search and replace).

2350 questions
4011
votes
37 answers

How can I pair socks from a pile efficiently?

Yesterday I was pairing the socks from the clean laundry and figured out the way I was doing it is not very efficient. I was doing a naive search — picking one sock and "iterating" the pile in order to find its pair. This requires iterating over n/2…
amit
  • 166,614
  • 24
  • 210
  • 314
56
votes
7 answers

How do I do a fuzzy match of company names in MYSQL with PHP for auto-complete?

My users will import through cut and paste a large string that will contain company names. I have an existing and growing MYSQL database of companies names, each with a unique company_id. I want to be able to parse through the string and assign to…
AFG
  • 1,587
  • 3
  • 21
  • 22
54
votes
10 answers

Matching numbers with regular expressions — only digits and commas

I can't figure out how to construct a regex for the example values: 123,456,789 -12,34 1234 -8 Could you help me?
user278618
  • 16,934
  • 41
  • 117
  • 192
51
votes
5 answers

Can a range be matched in Scala?

Is it possible to match a range of values in Scala? For example: val t = 5 val m = t match { 0 until 10 => true _ => false } m would be true if t was between 0 and 10, but false otherwise. This little bit doesn't work of course, but is…
Justin Poliey
  • 16,261
  • 7
  • 34
  • 47
50
votes
1 answer

select columns based on multiple strings with dplyr contains()

I want to select multiple columns based on their names with a regex expression. I am trying to do it with the piping syntax of the dplyr package. I checked the other topics, but only found answers about a single string. With base R: library(dplyr) …
agenis
  • 6,725
  • 4
  • 34
  • 83
41
votes
9 answers

Figure out if a business name is very similar to another one - Python

I'm working with a large database of businesses. I'd like to be able to compare two business names for similarity to see if they possibly might be duplicates. Below is a list of business names that should test as having a high probability of being…
Chris Dutrow
  • 42,732
  • 59
  • 174
  • 243
41
votes
9 answers

Regular expression matching fully qualified class names

What is the best way to match fully qualified Java class name in a text? Examples: java.lang.Reflect, java.util.ArrayList, org.hibernate.Hibernate.
Chun ping Wang
  • 3,619
  • 12
  • 39
  • 53
38
votes
4 answers

Recursive listing of all files matching a certain filetype in Groovy

I am trying to recursively list all files that match a particular file type in Groovy. This example almost does it. However, it does not list the files in the root folder. Is there a way to modify this to list files in the root folder? Or, is there…
shikarishambu
  • 2,159
  • 6
  • 34
  • 54
38
votes
7 answers

Check if value exists in column in VBA

I have a column of numbers of over 500 rows. I need to use VBA to check if variable X matches any of the values in the column. Can someone please help me?
Trung Tran
  • 9,709
  • 34
  • 97
  • 171
36
votes
2 answers

Compare Python Pandas DataFrames for matching rows

I have this DataFrame (df1) in Pandas: df1 = pd.DataFrame(np.random.rand(10,4),columns=list('ABCD')) print df1 A B C D 0.860379 0.726956 0.394529 0.833217 0.014180 0.813828 0.559891 0.339647 0.782838 0.698993 …
edesz
  • 8,579
  • 17
  • 58
  • 103
32
votes
4 answers

Pattern matching functions in Clojure?

I have used erlang in the past and it has some really useful things like pattern matching functions or "function guards". Example from erlang docs is: fact(N) when N>0 -> N * fact(N-1); fact(0) -> 1. But this could be expanded…
mikkom
  • 3,158
  • 4
  • 23
  • 35
32
votes
3 answers

Difference between * and node() in XSLT

What's the difference between these two templates?
Svish
  • 138,188
  • 158
  • 423
  • 589
31
votes
1 answer

When to use Rabin-Karp or KMP algorithms?

I have generated an string using the following alphabet. {A,C,G,T}. And my string contains more than 10000 characters. I'm searching the following patterns in it. ATGGA TGGAC CCGT I have asked to use a string matching algorithm which has O(m+n)…
Sukeshini
  • 1,131
  • 2
  • 21
  • 46
30
votes
3 answers

Improve matching of feature points with OpenCV

I want to match feature points in stereo images. I've already found and extracted the feature points with different algorithms and now I need a good matching. In this case I'm using the FAST algorithms for detection and extraction and the…
filla2003
  • 694
  • 1
  • 7
  • 18
30
votes
5 answers

Java 8 Pattern Matching?

Will Java 8 support pattern matching like Scala and other functional programs do? I'm putting a presentation together of Java 8's Lambda features. I can't find anything on this particular Functional-programming concept. I remember what got me…
edarroyo
  • 577
  • 1
  • 4
  • 9
1
2 3
99 100