compare

Word comparison algorithm

北战南征 提交于 2019-11-26 17:38:19
问题 I am doing a CSV Import tool for the project I'm working on. The client needs to be able to enter the data in excel, export them as CSV and upload them to the database. For example I have this CSV record: 1, John Doe, ACME Comapny (the typo is on purpose) Of course, the companies are kept in a separate table and linked with a foreign key, so I need to discover the correct company ID before inserting. I plan to do this by comparing the company names in the database with the company names in

Case insensitive comparison of strings in shell script

旧城冷巷雨未停 提交于 2019-11-26 17:27:34
问题 The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this? 回答1: if you have bash str1="MATCH" str2="match" shopt -s nocasematch case "$str1" in $str2 ) echo "match";; *) echo "no match";; esac otherwise, you should tell us what shell you are using. alternative, using awk str1="MATCH" str2="match" awk -vs1="$str1" -vs2="$str2" 'BEGIN { if ( tolower(s1) == tolower(s2) ){ print

How does PHP compare strings with comparison operators?

做~自己de王妃 提交于 2019-11-26 17:14:46
问题 I'm comparing strings with comparison operators. I needs some short of explanations for the below two comparisons and their result. if('ai' > 'i') { echo 'Yes'; } else { echo 'No'; } output: No Why do these output this way? if('ia' > 'i') { echo 'Yes'; } else { echo 'No'; } Output: Yes Again, why? Maybe I forgot some basics, but I really need some explanation of these comparison examples to understand this output. 回答1: PHP will compare alpha strings using the greater than and less than

Compare version strings in groovy

て烟熏妆下的殇ゞ 提交于 2019-11-26 17:13:33
问题 Hey I have created a Groovy script that will extract the version numbers of some folder. I would then like to compare the version numbers and select the highest. I got my script to run through the dir folder and I then get the versions in this format: 02.2.02.01 So I could get something like this: 02.2.02.01 02.2.02.02 02.2.03.01 I don't have them as a list but like this: baseDir.listFiles().each { file -> def string = file.getName().substring(5, 15) // do stuff } Also I have tested that

MVC3 CompareAttribute, client-side bug

廉价感情. 提交于 2019-11-26 16:39:30
问题 I am using MVC3 and I want to have LogIn form and Register form on the same page. To achieve that I built LogInRegisterViewModel as following: public class LogInRegisterViewModel { public LogInViewModel LogIn { get; set; } public RegisterViewModel Register { get; set; } } It gives me what I want (two forms on the same screen) and posts the data to correct controllers and returns and displays errors for forms (if any). The only problem I have is with CompareAttribute that I have above

How to compare two dates along with time in java

[亡魂溺海] 提交于 2019-11-26 16:27:23
问题 I have two Date objects with the below format. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); String matchDateTime = sdf.parse("2014-01-16T10:25:00"); Date matchDateTime = null; try { matchDateTime = sdf.parse(newMatchDateTimeString); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // get the current date Date currenthDateTime = null; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Date dt = new Date();

How can I use in_array if the needle is an array?

家住魔仙堡 提交于 2019-11-26 16:03:50
问题 I have 2 arrays, the value will be loaded from database, below is an example: $arr1 = array(1,2,3); $arr2 = array(1,2,3,4,5,6,7); What I want to do is to check if all the values in $arr1 exist in $arr2 . The above example should be a TRUE while: $arr3 = array(1,2,4,5,6,7); comparing $arr1 with $arr3 will return a FALSE . Normally I use in_array because I only need to check single value into an array. But in this case, in_array cannot be used. I'd like to see if there is a simple way to do the

NSArray containsObject method

拟墨画扇 提交于 2019-11-26 16:00:59
问题 I have a simple question regarding xcode coding but don't know why things are not performing as I think. I have an array of objects (custom objects). I just want to check if this one is within the array. I used the following code: NSArray *collection = [[NSArray alloc] initWithObjects:A, B, C, nil]; //A, B, C are custom "Item" objects Item *tempItem = [[Item alloc] initWithLength:1 width:2 height:3]; //3 instance variables in "Item" objects if([collection containsObject:tempItem]) { NSLog(@

How to compare a list of lists/sets in python?

筅森魡賤 提交于 2019-11-26 15:48:23
问题 What is the easiest way to compare the 2 lists/sets and output the differences? Are there any built in functions that will help me compare nested lists/sets? Inputs: First_list = [['Test.doc', '1a1a1a', 1111], ['Test2.doc', '2b2b2b', 2222], ['Test3.doc', '3c3c3c', 3333] ] Secnd_list = [['Test.doc', '1a1a1a', 1111], ['Test2.doc', '2b2b2b', 2222], ['Test3.doc', '8p8p8p', 9999], ['Test4.doc', '4d4d4d', 4444]] Expected Output: Differences = [['Test3.doc', '3c3c3c', 3333], ['Test3.doc', '8p8p8p',

What is the proper function for comparing two C-style strings?

此生再无相见时 提交于 2019-11-26 14:46:50
问题 So I have a dilemma. I need to compare two C-style strings and I searched for the functions that would be the most appropiate: memcmp //Compare two blocks of memory (function) strcmp //Compare two strings (function ) strcoll //Compare two strings using locale (function) strncmp //Compare characters of two strings (function) strxfrm //Transform string using locale (function) The first one I think is for addresses, so the idea is out. The second one sounds like the best choice to me, but I