string-comparison

MySQL DATETIME format comparison - is strtotime needed?

I've been doing something along the lines of.. $dt1 = '1000-01-01 00:00:00'; //really some val from db $dt2 = '1000-01-01 00:00:10'; //another val maybe db maybe formatted if(strtotime($dt1) > strtotime($dt2){ //do something } Is the strtotime needed? can i do a more direct comparison on the datetime formatted strings? i.e. if($dt1...

How can I partial compare two strings in C?

Hi, Let's say I have the following content: Lorem Ipsum is simply dummy text of the printing and typesetting industry. How do I search for dummy or dummy text in that string using C? Is there any easy way to do it or only with strong string manipulation? All I need is to search for it and return a Boolean with the result. EDIT: You ...

Sort Strings by first letter [C]

I have a program which places structures in a linked list based on the 'name' they have stored in them. To find their place in the list, i need to figure out if the name im inserting is earlier or later in the alphabet then those in the structures beside it. The names are inside the structures, which i have access to. I don't need a fu...

null pointer exception comparing two strings in java.

I got this error message and I'm not quite sure whats wrong: Exception in thread "main" java.lang.NullPointerException at Risk.runTeams(Risk.java:384) at Risk.blobRunner(Risk.java:220) at Risk.genRunner(Risk.java:207) at Risk.main(Risk.java:176) Here is the relevant bits of code (i will draw attention to the line numb...

Find a name in a list if the name is spelt wrong

I've got a list of names which some code checks against to see if the person exists, and if so do some stuff.. My issue is that I want to handle the case of the name being entered incorrectly.. I.e. I have a list of names Bob Frank Tom Tim John If I type in Joohn, I want it to ask me if I meant John. If I type Tm, I get asked if I m...

string Comparison

I want to compare two user input strings, but not able to do so... #include "stdafx.h" #include "iostream" #include "string" using namespace std; int _tmain(int argc, _TCHAR* argv0[]) { string my_string; string my_string2; cout<<"Enter string"<<endl; cin>>my_string; cout<<"Enter 2nd string"<<endl; cin>>my_string...

C# matching two text files, case sensitive issue

What I have is two files, sourcecolumns.txt and destcolumns.txt. What I need to do is compare source to dest and if the dest doesn't contain the source value, write it out to a new file. The code below works except I have case sensitive issues like this: source: CPI dest: Cpi These don't match because of captial letters, so I get i...

compare two windows paths, one containing tilde, in python

I'm trying to use the TMP environment variable in a program. When I ask for tmp = os.path.expandvars("$TMP") I get C:\Users\STEVE~1.COO\AppData\Local\Temp Which contains the old-school, tilde form. A function I have no control over returns paths like C:\Users\steve.cooper\AppData\Local\Temp\file.txt My problem is this; I'd lik...

Comparison of music data

Hey I am looking for theory, algorithms and similar for how to compare music. More specifically, I am looking into how to dupecheck music tracks that have different bitrates or perhaps slightly different variations (radio vs album version), but otherwise sound the same. Use cases for this include services such as Grooveshark, Youtube, ...

How do you tell if two wildcards overlap?

Given two strings with * wildcards, I would like to know if a string could be created that would match both. For example, these two are a simple case of overlap: Hello*World Hel* But so are all of these: *.csv reports*.csv reportsdump.csv Is there an algorithm published for doing this? Or perhaps a utility function in Windows or...

How to Compare two strings using a if in a stored procedure in sql server 2008?

I want to do something like this: declare @temp as varchar set @temp='Measure' if(@temp == 'Measure') Select Measure from Measuretable else Select OtherMeasure from Measuretable ...

varchar comparison in SQL Server

I am looking for some SQL varchar comparison function like C# string.compare (we can ignore case for now, should return zero when the character expression are same and a non zero expression when they are different) Basically I have some alphanumeric column in one table which needs to be verified in another table. I cannot do select A...

iPhone OS: making a switch statement that uses string literals as comparators instead of integers

So i'd like to do this: switch (keyPath) { case @"refreshCount": //do stuff case @"timesLaunched": //do other stuff } but apparently you can only use integers as the switch quantity. Is the only way to do this parse the string into an integer identifier and then run the switch statement? like this: nsinteger n...

strnicmp equivalent for UTF-8?

What do I use to perform a case-insensitive comparison on two UTF-8 encoded sub-strings? Essentially, I'm looking for a strnicmp function for UTF-8. ...

Beautify Integer values for comparing as strings

Hi. For some reason I need to enter my integer values to database as string, then I want to run a query on them and compare those integers as strings. Is there any way to beautify integer numbers (between 1 and 1 US billion as an example) so I can compare them as strings? Thanks in advance. ...

Make entity framework case-insensitive

Is it possible to set entity framework string comparison case insensitive by default? If I use string.StartsWith("stringToCompare", StringComparison.CurrentCultureIgnoreCase), it works. But when I need to use string.Contains("strigToCompare") it doesn't have an overload. ...

Compare two String with MySQL

Hi, I wan't to compare two strings in a SQL request so I can retrieve the best match, the aim is to propose to an operator the best zip code possible. For example, in France, we have Integer Zip code, so I made an easy request : SELECT * FROM myTable ORDER BY abs(zip_code - 75000) This request returns first the data closest of Paris....

A beginner's guide to interpreting Regex?

Greetings. I've been tasked with debugging part of an application that involves a Regex -- but, I have never dealt with Regex before. Two questions: 1) I know that the regexes are supposed to be testing whether or not two strings are equivalent, but what specifically do the two regex statements, below, mean in plain English? 2) Does a...

String comparision not working correctly?

I'm using this library to hook keys and I have some problems with comparing e.KeyCode.ToString() with same string. I have variable which is string equivalent of Keys.Oemtilde -> Program.KeyboardTradeHotkey = "Oemtilde"; I keep it in string because I read that string from xml file and I can't seem to get any way to convert string to ...

When should Regex be used over String.IndexOf()? or String.Contains()?

Hey all, I'm, currently working my first project in .NET 4.0 and it requires several thousand string comparisons (I'm searching directories and sometimes entire drives for certain files). For the most part, the strings are quite short because I'm only looking at file paths so I have just made use of String.Contains() to see if the file...