string-comparison

Best way to compare the end of a string, use RIGHT, LIKE or other?

*爱你&永不变心* 提交于 2019-12-04 10:34:45
问题 I need to compare the end of strings against a list of possible ending in a stored procedure. It will be called a lot and there are around 10-15 candidate endings. At this point a code-only solution is preferable to creating tables dedicated to this. Something that would be like: IF (ENDSWITH(@var, 'foo') OR ENDSWITH(@var, 'bar') OR ENDSWITH(@var, 'badger') OR ENDSWITH(@var, 'snake')) ( ) I'm looking for the best way in terms of speed, but also maintainability. Candidates that I know of are

MIPS - compare input string to one stored in memory

笑着哭i 提交于 2019-12-04 10:28:44
I have a functioning string compare method written in MIPS (bit by bit comparison of two strings from an input by the user), but I'm trying to update it to compare the second input with one that I have stored in memory. (If those two are equal, I want to use the first string somewhere else). However, I'm running into some issues. Here's my code: .data str1: .space 20 str2: .space 20 msg1:.asciiz "Please enter string (max 20 characters): " msg2: .asciiz "\n Please enter method (max 20 chars): " msg3:.asciiz "\nSAME" msg4:.asciiz "\nNOT SAME" .text .globl main main: li $v0,4 #loads msg1 la $a0

Is Nullable<int> a “Predefined value type” - Or how does Equals() and == work here?

梦想的初衷 提交于 2019-12-04 09:57:25
问题 For my own implementation of an Equals() method, I want to check a bunch of internal fields. I do it like this: ... _myNullableInt == obj._myNullableInt && _myString == obj._myString && ... I would assume, that this compares the values, including null, for equality not the object address (as a reference euqality compare operation would) because: It is said so for "predefined value types" in this MSDN doc here. I assume Nullable<int> is such a "predefined value type" because of it is in the

Word by word diff comparison of two strings in .NET

社会主义新天地 提交于 2019-12-04 09:42:23
I need to do Word by word comparison of two strings. Something like diff, but for words, not for lines. Like it is done in wikipedia http://en.wikipedia.org/w/index.php?title=Horapollo&action=historysubmit&diff=21895647&oldid=21893459 In result I want return the two arrays of indexes of words, which are different in two string. Are there any libraries/frameworks/standalone_methods for .NET which can do this? P.S. I want to compare several kilobytes of text Actually, you probably want to implement a variation of the Local Alignment/Global Alignment algorithms we use in DNA sequence alignments .

'Regular Expression' VS 'String Comparison operators / functions'

落爺英雄遲暮 提交于 2019-12-04 06:52:00
This question is designed around the performance within PHP but you may broaden it to any language if you wish to. After many years of using PHP and having to compare strings I've learned that using string comparison operators over regular expressions is beneficial when it comes to performance. I fully understand that some operations have to be done with Regular Expressions down to there complexity but for operations that can be resolved via regex AND string functions. take this example: PHP preg_match('/^[a-z]*$/','thisisallalpha'); C# new Regex("^[a-z]*$").IsMatch('thisisallalpha'); can

Difference of stricmp and _stricmp in Visual Studio?

若如初见. 提交于 2019-12-04 03:23:33
I may asking a stupid question, but I really can't find an answer with google plus I am still a beginner of using MSVS. I recently need to use functions to make comparison of two strings. What I don't understand is the difference of stricmp and _stricmp. They both can be used to compare strings and return the same results. I went to check them: char string1[] = "The quick brown dog jumps over the lazy fox"; char string2[] = "The QUICK brown dog jumps over the lazy fox"; void main( void ) { char tmp[20]; int result; /* Case sensitive */ printf( "Compare strings:\n\t%s\n\t%s\n\n", string1,

Split a string and return greatest in mssql

北慕城南 提交于 2019-12-04 01:17:34
问题 I need to find a way to get the data with the highest versionNumber. Here is my database design: VERSIONNUMBER - varchar(15) DOWNLOADPATH - varchar(100) Lets say I have records like: VERSIONNUMBER -------- DOWNLOADPATH 1.1.2 a.com 1.1.3 b.com 2.1.4 c.com 2.1.5 d.com 2.2.1 e.com I need to get the record with the versionnumber 2.2.1. Need some help with the sql though :) Thank you for any help 回答1: Try this: with a as ( select * from (values ('1.1.2'),('1.1.3'),('2.1.4 '), ('2.1.5'), ('2.2.1')

Force localeCompare to be case-sensitive

我只是一个虾纸丫 提交于 2019-12-04 00:33:11
I'm trying to use JavaScript's localeCompare function for sorting strings. I was surprised by the results of running the following lines in the devTools console: "a".localeCompare("b") // returns: -1 "A".localeCompare("b") // returns: -1 Another test: "b".localeCompare("a") // returns: 1 "B".localeCompare("a") // returns: 1 Even when I am more specific about my sort I get the same result: "a".localeCompare("b", { usage: "sort", sensitivity: 'variant' }) // -1 "A".localeCompare("b", { usage: "sort", sensitivity: 'variant' }) // -1 "b".localeCompare("a", { usage: "sort", sensitivity: 'variant' }

String Comparison And Alphabetic Order of Individual Characters

我的未来我决定 提交于 2019-12-04 00:23:25
I have a question related to string comparison vs. character comparison. Characters > and 0 (zero) have following decimal values 62 and 48 accordingly. When I compare two characters in the following code, I get value True (which is correct) Console.WriteLine('>' > '0'); When I compare two one-character strings in the following code, I get value -1 which indicates that ">" is less than "0" (default culture is English) Console.WriteLine(string.Compare(">", "0")); Whereas comparison of "3" and "1" ( 51 and 49 code values) in the following code returns 1 (as expected) Console.WriteLine(string

Case insensitive string comparison in Go

巧了我就是萌 提交于 2019-12-04 00:00:19
How do I compare strings in a case insensitive manner? For example, "Go" and "go" should be considered equal. https://golang.org/pkg/strings/#EqualFold is the function you are looking for. It is used like this (example from the linked documentation): package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.EqualFold("Go", "go")) } 来源: https://stackoverflow.com/questions/30196780/case-insensitive-string-comparison-in-go