string-comparison

Best way to compare 2 urls [closed]

Deadly 提交于 2019-12-10 02:34:50
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I want to compare 2 URLs. Whats the best way to do this? Conditions: 1) It should exclude the http scheme. 2) 'foo.com/a/b' and 'foo.com/a' should be a match. 回答1: You should use the Uri.Compare method. Here is an example to compare two URI's with different schemes. public static void Test() { Uri uri1 = new Uri

How to fetch entries starting with the given string from a SQL Server database?

只谈情不闲聊 提交于 2019-12-10 01:50:07
问题 I have a database with a lot of words to be used in a tag system. I have created the necessary code for an autocomplete box, but I am not sure of how to fetch the matching entries from the database in the most efficient way. I know of the LIKE command, but it seems to me that it is more of an EQUAL command. I get only the words that looks exactly like the word I enter. My plan is to read every row, and then use C#'s string.StartsWith() and string.Contains() functions to find words that may

O(N) Identification of Permutations

若如初见. 提交于 2019-12-09 11:55:39
问题 This answer determines if two strings are permutations by comparing their contents. If they contain the same number of each character, they are obviously permutations. This is accomplished in O(N) time. I don't like the answer though because it reinvents what is_permutation is designed to do. That said, is_permutation has a complexity of: At most O(N 2 ) applications of the predicate, or exactly N if the sequences are already equal, where N=std::distance(first1, last1) So I cannot advocate

Can I use != and == in C++ for string comparison without writing my own?

北城以北 提交于 2019-12-08 13:11:23
问题 What's difference between C and C++ in string comparison in other words? I came from 'C' camp. I saw program using == to compare strings, I tried to find its overloading program, but did not find one. Does it mean C++ deal with string (char []) naturally with == and !=? If I have my own defined String class, would it be same that I can use == and != without defining them? or it applies only to char []? Edit: It looks like I mixed C's char[] with C++ std::string class. OK, the old question

(fast) pairwise comparison of matrix columns whose elements have “a/b” format

不问归期 提交于 2019-12-08 05:24:43
问题 I have a big character matrix (15000 x 150), and with the following format: A B C D [1,] "0/0" "0/1" "0/0" "1/1" [2,] "1/1" "1/1" "0/1" "0/1" [3,] "1/2" "0/3" "1/1" "2/2" [4,] "0/0" "0/0" "2/2" "0/0" [5,] "0/0" "0/0" "0/0" "0/0" I need to do pairwise comparison between columns and get the proportion of rows where neither string separated by '/' is equal (coded as 0); only one string separated by '/' is equal (coded as 1); both strings separated by '/' are equal (coded as 2). The expected

Check if a string contains specific characters using VBS script

[亡魂溺海] 提交于 2019-12-07 10:54:23
问题 My script is doing the following point : Retrieve all my selected folder files Class them by date (From the recent one to the older) Show them in a window Here is my VBS Script (I retrieve it here): Option Explicit Const PathMDB = "C:\Users\C8461789\Desktop\test_script" MsgBox TriRepertoire,,"Enumération " & PathMDB '---lister les fichiers du répertoire --- Function TriRepertoire() Dim fso, fichier, fileItem Dim i, imax, z, valeur, cible, liste Set fso = CreateObject("Scripting

Compare Strings as if they were numbers

谁都会走 提交于 2019-12-07 09:42:56
问题 I was wondering if it is possible to compare strings as if they were numbers. For instance is there any way you could make it so that "Cat" > "Dog" 回答1: Since the only way to do this is to keep a set value for each word, you'd be using arrays, or some other form of data storage. Here is an example where you just keep the words, and their corresponding values in two arrays (note, they must be in the same order, so the first word corresponds with the first number, etc). public static String[]

Make Entity Framework be case-insensitive

有些话、适合烂在心里 提交于 2019-12-07 04:02:54
问题 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. 回答1: You can simply change the case of both fields to Upper Case: String stringToCompare = "Some String"; string.ToUpper().Contains(stringToCompare.ToUpper()) This will make the search case-insensitive by converting all case

Comparing strings with the format “2.0.1”, “2.0.09”

故事扮演 提交于 2019-12-07 03:11:59
问题 I need to get the user's app version number and compare it with the current app version on my server. If the user's app version is lower, then he will get a pop-up to update his app. While doing this, I need to compare the version of the app with the versions that are available. How can I compare the strings which are in the format "2.0.1" and "2.0.09" and get the highest one, in Objective-C? 回答1: How about using the compare:options: method of the NSString class? NSString *v1 = @"2.0.1";

locale aware string comparision

狂风中的少年 提交于 2019-12-06 11:03:44
I´m using strcmp in combination with usort in order to sort an array of country names. Currently, the sort order is: Belgien Frankreich Italien Luxemburg Niederlande Spanien United Kingdom Österreich Which is correct, apart from the position of Österreich . It should be between Niederlande and Spanien . I also tried strnatcmp and strcoll (with setlocale ), but the sort order was not the way I wanted it. The results are not from a mysql db, so sorting via a mysql query is not an option. Old question, meanwhile I am working at another company on another project, but faced recently the same