pattern-matching

Can anyone explain UriMatcher (Android SDK)?

I have been tasked with designing my web services client code to use the utility class UriMatcher in the Android SDK. Unfortunately, the example in the Dev Guide does not relate to anything in my mind. I know I am missing some fundamental points to the functionality and possibly about Uri itself. If you can tie it to some web APIs tha...

Scala: Matching optional Regular Expression groups

I'm trying to match on an option group in Scala 2.8 (beta 1) with the following code: import scala.xml._ val StatementPattern = """([\w\.]+)\s*:\s*([+-])?(\d+)""".r def buildProperty(input: String): Node = input match { case StatementPattern(name, value) => <propertyWithoutSign /> case StatementPattern(name, sign, value) => <p...

pattern matching

Hi every body Consider the following rules: register * delete * suppose now if I send a message to the application (via mobile using SMS) that will match the rules register Leon Eric now we have two parameter Leon and Eric and the application will assign %P1% for Leon and %P2% for Eric , for further use. it can be more paramete...

Is there some algorithm to compare the DOM similarity of different pages ?

Has anyone some experience about this? ...

Print a string that contains a certain pattern in Java

I am trying to find a regular expression within a line of a .csv file, so I can eventually save all the matches to another file, and lose all the other junk. So a line in my file might look like: MachineName,User,IP,VariableData,Location The VariableData is what I want to match, and if there's a match, print the line. I am using a patt...

How to adjust SQL LIKE function?

I want to make this kind of query: create procedure something @name varchar(13) as begin select * from WORKER where NAME LIKE "%@name%" end For input @name=ho, I want output every row that contains NAME wich sounds "ho", for example HOuse, soHO, broHOw... ...

pattern matching in Bash

Hi, Here is an example to get different parts of a filename bash-3.2$ pathandfile=/tmp/ff.txt bash-3.2$ filename=$(basename $pathandfile) bash-3.2$ echo $filename ff.txt bash-3.2$ echo ${filename##*.} txt bash-3.2$ echo ${filename%.*} ff I was wondering what does ## and % mean in the patterns. How is the ...

What is 'Pattern Matching' in functional languages?

I'm reading about functional programming (in academic purpose) and I've noticed that Pattern Matching is mentioned in many articles as one of the core features of functional languages. Can someone explain for a Java/C++/JavaScript developer what does it mean? ...

How can I use JavaScript to match a string inside the current URL of the window I am in?

Hi, I have used the excellent gskinner.com/RegExr/ tool to test my string matching regex but I cannot figure out how to implement this into my JavaScript file to return true or false. The code I have is as follows: ^(http:)\/\/(.+\.)?(stackoverflow)\. on a url such as http://stackoverflow.com/questions/ask this would match (accordin...

File Comparison Strategies

I'm searching for strategies one might use to programmatically find files which may be duplicates of each other. Specifically in this case, videos. I'm not looking for exact matches (as nice as that would be in the land of rainbows and sunshine). I'm just looking to collect pairs of video which content might be the same so that a huma...

Ranking based string matching algorithm..for Midi Music

i am working on midi music project. What i am trying to do is:- matching the Instrument midi track with the similar instrument midi track... for example Flute track in a some midi music is matched against the Flute track in some other music midi file... After matching ,the results should come ranking wise according to their similarity....

How is Google Calculator implemented ?

When you search in Google "100F to C" how does it know to convert from Fahrenheit to Celsius? Similarly, conversion from different currencies and simple calculation. What is the data structure used, or is it simple pattern matching the strings? ...

Very simple regex not working

I have read that to match a word inside of a string using Regular expressions (in .NET), I can use the word boundary specifier (\b) within the regex. However, none of these calls result in any matches Regex.Match("INSERT INTO TEST(Col1,Col2) VALUES(@p1,@p2)", @"\b@p1\b"); Regex.Match("INSERT INTO TEST(Col1,Col2) VALUES(@p1,@p2)", @"\bI...

A couple of pattern matching issues with pattern matching in Lua

I'm fairly new to lua programming, but I'm also a quick study. I've been working on a weather forecaster for a program that I use, and it's working well, for the most part. Here is what I have so far. (Pay no attention to the zs.stuff. That is program specific and has no bearing on the lua coding.) if not http then http = require("so...

"User Friendly" .net compatible Regex/Text matching tools?

Currently in our software we provide a hook where we call a DLL built by our clients to parse information out of documents we are processing (the DLL takes in some text (or a file) and returns a list of name/value pairs). e.g. We're given a Word doc or Text file to Archive. We do various things to the file, and call a DLL that will retu...

How to match a variable list of items separated by commas

I want to turn something like this CS 240, CS 246, ECE 222, ... (more or less); Software Engineering students only into ('CS 240', 'CS 246', 'ECE 222', 'ECE 220') in Python, code that matches a single course looks like >>> re.search('([A-Z]{2,5} \d{3})', 'SE 112').groups() ('SE 112',) I prefer a regular expression only method be...

Problem with literal arguments in the PATTERN string for a python 2to3 fixer

Hi folks. I'm writing a fixer for the 2to3 tool in python. In my pattern string, I have a section where I'd like to match an empty string as an argument, or an empty unicode string. The relevant chunk of my pattern looks like: (args='""' | args='u""') My issue is the second option never matches. Even if it's alone, it won't match. Ho...

Matching and deleting items in list of tuples

I have a list of tuples, say [{x, a, y}, {x, b, y}]. Is there a built-in function (or can I use a combination of BIFs) to delete all tuples matching {x, _, y}, as in match and delete based on the first and third term in the tuples, ignoring the second? ...

SQL Server - Searching string with international characters using LIKE clause

Hi, I have a field 'Description' which can have product descriptions with any unicode characters. If I search for a description which contains an international character, with a LIKE condition (word searched with does not have the international character) I get the following results: Ex: GEWÜRZTRAMINER is one of the descriptions. When ...

Scala XML Pattern matching and Attributes

Hi StackOverflow Community! First of all: I'm at Scala 2.8 I have a slight Issue while using pattern matching on XML elements. I know I can do smth. like this: val myXML = <a><b>My Text</b></a> myXML match { case <a><b>{theText}</b></a> => println(theText) case _ => } This is the sort of example I find everywhere on the net ...