pattern-matching

how to match this type of construction?

im doing parsing and the kind of text that i want to match and then make it null is as follows :- <tr class="label-BGC"><td colspan="4">any kind of text here</td></tr> i want to match every line that contains "<tr class="label-BGC"><td colspan="4">any text</td></tr>" its evening here and my brain-battery is totally down what im try...

How can I detect common substrings in a list of strings

Given a set of strings, for example: EFgreen EFgrey EntireS1 EntireS2 J27RedP1 J27GreenP1 J27RedP2 J27GreenP2 JournalP1Black JournalP1Blue JournalP1Green JournalP1Red JournalP2Black JournalP2Blue JournalP2Green I want to be able to detect that these are three sets of files: EntireS[1,2] J27[Red,Green]P[1,2] JournalP[1,2][Red,Green,B...

SQL query - LEFT 1 = char, RIGHT 3-5 = numbers in Name

Hi everyone I need to filter out junk data in SQL (SQL Server 2008) table. I need to identify these records, and pull them out. Char[0] = A..Z, a..z Char[1] = 0..9 Char[2] = 0..9 Char[3] = 0..9 Char[4] = 0..9 {No blanks allowed} Basically, a clean record will look like this: T1234, U2468, K123, P50054 (4 record examples) Junk d...

How can I use PCRE to get all match groups?

Hi, I am inexperienced with using C, and I need to use PCRE to get matches. Here is a sample of my source code: int test2() { const char *error; int erroffset; pcre *re; int rc; int i; int ovector[OVECCOUNT]; char *regex = "From:([^@]+)@([^\r]+)"; ...

What's the most effective way to match out data from <table > with PHP?

For example,to strip out key/value pairs from html like below: <tr> <td id="td3" class="td3" bgcolor="#FFFFFF" colspan="4">■ Related Information </td> </tr> <tr> <td id="td5" class="td5" width="10%">job title:</td> <td id="td5" class="td5" width="90%" colspan="3">Sales Representitive</t...

How to escape a string for use with the LIKE operator in SQL Server?

I am looking for something that works in SQL Server similar to the @ symbol in c# which causes a string to be taken as it's literal. Eg: string text = "abcd\\efg"; Output of text = abcd\efg string text = @"abcd\\efg"; Output of text = abcd\\efg Note how the @ affected the string to take every character as is. Now I am not sure this...

regular expression for content within braces

hi there, is there a regular expression to match the content within braces. For example with the following: d = {'key': {'a': [1,2,3]}} I would want to match {'key': {'a': [1,2,3]}} and {'a': [1,2,3]}, but not {'key': {'a': [1,2,3]} ...

USING THE SQL LIKE OPERATOR WITH %%

I had a requirement to create a query in MS SQL where the search condition would include/exclude a table based on user input. Say I have two tables’ TABLE_A and TABLE_B with columns KEYCOLUMN_A, COLUMN_A in TABLE_A and columns FKCOLUMN_B, COLUMN_B in TABLE_B And a query like SELECT TABLE_A.* FROM TABLE_A, TABLE_B WHERE TABLE_A.KEYCOLU...

Does "match ... true -> foo | false -> bar" have special meaning in Ocaml?

I encountered the following construct in various places throughout Ocaml project I'm reading the code of. match something with true -> foo | false -> bar At first glance, it works like usual if statement. At second glance, it.. works like usual if statement! At third glance, I decided to ask at SO. Does this construct have spec...

How to use SIFT algorithm to compute how similiar two images are?

I have used the SIFT implementation of Andrea Vedaldi, to calculate the sift descriptors of two similar images (the second image is actually a zoomed in picture of the same object from a different angle). Now I am not able to figure out how to compare the descriptors to tell how similar the images are? I know that this question is not ...

Recognizing striked out handwritten words

I am working on handwriting recognition and related stuff on visual studio platform and using openCV libraries. Input is in the form of binary scanned .tif images. Currently I went into a roadblock trying to figure out a way to recognize striked out words as in you strike out (cancel) words using a straight/ curved line. I am not going ...

Pattern match data types and their nested name in Haskell

I have: data Color = Blue | Green | Red | White | Yellow deriving (Eq,Ord) And then data Term = Color | ... data Bag = Bag { color :: Color ... } Now I want to be able to pattern match to make sure that the term given is a Color and if so check it's "value" (Blue/Green...). Something like this: func :: Term -> Bag -> Bool func (c ...

How can I code this problem? (C++)

I am writing a simple game which stores datasets in a 2D grid (like a chess board). Each cell in the grid may contain a single integer (0 means the cell is empty). If the cell contains a number > 0, it is said to be "filled". The set of "filled" cells on the grid is known as a "configuration". My problems is being able to "recognize" a ...

Pattern matching zero-argument functions in scala: mystified by warning

I'm playing with scala's distributed actors. Very nice. I have a server which executes incoming function objects. For example, the client has object Tasks { def foo = {Console.println("I am Foo")}; def bar = {Console.println("I am Bar");} } // In client actor... ... server ! Tasks.foo _ ... And the server can pick these up an...

javascript - search multiple html #ID and pass to function

Hiya, I've got an order form, to which I can append fields by clicking a button. I've got some back end javascript running which totals up the order price, but the grand total script is eluding me. My problem is that I need the script to seach the entire DOM and find how many have an ID which matches the following pattern. totprice0...

Using vi, how can I remove all lines that contain [searchterm]?

I want to remove all lines in a CSS file that contain the word "color". This would include: body {background-color:#000;} div {color:#fff;} How would you do that using the :%s/ command? ...

How to match columns in MySQL.

Everyone knows the "=" sign. SELECT * FROM mytable WHERE column1 = column2; However, what if I have different contents in column1 and column2...but they are VERY similar? (maybe off by a space, or have a word that's different). Is it possible to: SELECT * FROM mytable WHERE ....column matches column2 with .4523423 "Score"... I bel...

Count word occurrences in a text field with LINQ

How can i get the occurrences count of a Word in a database text field With LINQ ? Keyword token sample : ASP.NET EDIT 4 : Database Records : Record 1 : [TextField] = "Blah blah blah ASP.NET bli bli bli ASP.NET blu ASP.NET yop yop ASP.NET" Record 2 : [TextField] = "Blah blah blah bli bli bli blu ASP.NET yop yop ASP.NET" Record 3 : ...

Linq Pattern Matching

I am using Regular Expression for matching patterns say example in the follwoing example i am matching string to count vowels. void VowelsCountInEachWord() { Regex rx = new Regex("[aeiou]"); var words=new string[] {"aesthetic", "benevolent", "abstract", "capricious", "complacent",...

Using comparison operators in Scala's pattern matching system.

Is it possible to match on a comparison using the pattern matching system in Scala? For example: a match { case 10 => println("ten") case _ > 10 => println("greater than ten") case _ => println("less than ten") } The second case statement is illegal, but I would like to be able to specify "when a is greater than". ...