string-comparison

Comparing strings with tolerance

妖精的绣舞 提交于 2019-12-17 04:15:02
问题 I'm looking for a way to compare a string with an array of strings. Doing an exact search is quite easy of course, but I want my program to tolerate spelling mistakes, missing parts of the string and so on. Is there some kind of framework which can perform such a search? I'm having something in mind that the search algorithm will return a few results order by the percentage of match or something like this. 回答1: You could use the Levenshtein Distance algorithm. "The Levenshtein distance

Using R to process CSV to evaluate if ((ColA != ColB) with consideration for ColC

北城余情 提交于 2019-12-16 18:03:49
问题 I'm trying to achieve a simple string comparison across two columns. Sample of (mocked up) data: EMPLID,From_DeptCode,FromDept,To_DeptCode,To_Dept,TransactionTypeCode,TransactionType,EffectiveDate,ChangeType 0239583290,21,Sales,43,CustomerService,10,Promotion,12/12/2012 1230495829,21,Sales,21,Sales,10,Promotion,9/1/2013 4059503918,93,Operations,93,Operations,10,Demotion,11/18/2014 3040593021,19,Headquarters,23,International,11,Reorg,12/13/2011 7029406920,15,Marketing,84,Development,19

Get an entire string or a substring, depending on a specific character

守給你的承諾、 提交于 2019-12-14 02:18:14
问题 I have a string that contains a MIME type, say application/json . Now I want to compare this against an actual HTTP header, in this case content-type . If the header contains the MIME type, then it's as easy as: if (mimeType === contentType) { ... } Unfortunately, the header may contain additional parameters. They always come after the value I'm interested in, and they are separated from it by a ; . E.g., it could be application/json; charset=UTF-8 . So now basically I need to run: if

allow accented characters to be searchable? [duplicate]

99封情书 提交于 2019-12-14 01:54:30
问题 This question already has answers here : Closed 7 years ago . SOLVED: I used the following code: var compareinfo = CultureInfo.CurrentCulture.CompareInfo; var index = compareinfo.IndexOf(strA, strB, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase); return index > -1; Possible Duplicate: Ignoring accented letters in string comparison I have a public Kiosk application where users use it to search for a place of interest. Say I have a shop name with the Café word. The kiosk only allows

Comparing Strings in Swift 3 gives false results (Linux)

随声附和 提交于 2019-12-13 08:07:55
问题 I don't understand the way Swift compares strings. Swift (3.0.2) on Linux: print("2" < "=") //returns false but other languages such as Ruby: p("2:" < "=:") #returns true It seems we should have swift returning true since "2" comes before "=" in ASCII order. Is it a bug or do I miss something? 回答1: From the comments, it seems that you are testing this on Linux only. There is an open bug how Swift handles char ordering on Linux, see SR-530 Original answer: Ruby's p returns object passed as its

== vs .equals - why different behaviour? [duplicate]

巧了我就是萌 提交于 2019-12-12 19:44:30
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I compare strings in Java? I'm sorry for this rather simple question. I have this very simple java program: public class ArgIt { public static void main(String[] args){ if(args[0].equals("x")) System.out.print("x"); if(args[0] == "x") System.out.println("x2 "); } } If I call the program >java ArgIt x it only prints a single x. Why will the program not acknowledge the == on the string when in any other

How to check if a string contains any string of a column in MySQL and vice versa?

爷,独闯天下 提交于 2019-12-12 18:27:05
问题 By vice versa, I mean, check if any of the strings in a column contains the string. Example: String a = "Peperoni" MySQL column: { "PPeperoni_123", "roni", "hello world" } It should return the first 2 rows. (Note: im looking for the query string for this) 回答1: Not sure if I understand you correctly, but are you maybe looking for this: SELECT ... WHERE column LIKE "%string%" OR string LIKE CONCAT("%", column, "%") 回答2: with Mysql you can use SOUNDS LIKE to find the nearest matches example

C# String greater than or equal code string

痞子三分冷 提交于 2019-12-12 10:59:43
问题 // Hello, Im trying to get my code working my comparing if a string is bigger or less than 10, but it doesn't work correctly. It writes 10 or more even if the value is less than 10. int result = string1.CompareTo("10"); if (result < 0) { Console.WriteLine("less than 10"); } else if (result >= 0) { Console.WriteLine("10 or more"); } 回答1: A string is not a number, so you're comparing lexicographically(from left to right). String.CompareTo is used for ordering, but note that "10" is "lower" than

Match strings stored in variables using PowerShell

家住魔仙堡 提交于 2019-12-12 09:46:46
问题 I am attempting to create a backup script that will move files that are older that 30 days, but I want to be able to exclude folders from the list $a = "C:\\Temp\\Exclude\\test" $b = "C:\\Temp\\Exclude" if I run the following: $a -match $b Following PowerShell Basics: Conditional Operators -Match -Like -Contains & -In -NotIn: $Guy ="Guy Thomas 1949" $Guy -match "Th" This returns true . 回答1: I'd say use wilcards and the like operator, it can save you a lot of head aches: $a -like "$b*" The

How to compare strings in which appears similar characters but different char codes?

家住魔仙堡 提交于 2019-12-12 04:22:11
问题 I have the problem with comparing strings with different char codes but similar characters like the following: console.log('³' === '3') // false; False value from the code above because of different char codes: console.log('³'.charCodeAt(0)) // 179 console.log('3'.charCodeAt(0)) // 51 What is a universal solution to convert values to be equals? I need it because I need to compare all numbers like 1,2,3,4,5.... Thanks 回答1: Look into ASCII folding, which is primarily used to convert accented