FAQ Database Discussion Community


SSIS: How to check if string value from one column of a table matches with string value (from the right) in a column of another table?

ssis,string-comparison
I am pretty new to SSIS and below is the SQL query which explains what I am trying to do: select * from Table1 t1 join (Select ID, LEN(ID) as len from Table2) as t2 on RIGHT(RTRIM(t1.col) , t2.len) = t2.ID There might be some better query in SQL for...

MySQL: Get rows with creation date string newer than given date string

mysql,prepared-statement,string-comparison
I am trying to create a prepared statement with following code: $statement = $db->prepare("SELECT * FROM myTable WHERE STR_CMP(creationDate, $startingDate) = 1 ORDER BY creationDate DESC "); I have also tried this: $statement = $db->prepare("SELECT * FROM myTable WHERE (creationDate > $startingDate) = 1 ORDER BY creationDate DESC "); But...

Normalize strings that represent (combinatorical) necklaces [closed]

python,combinatorics,string-comparison,string-matching
I'm trying to match "necklaces" of symbols in Python by looking up their linear representations, for which I use normal strings. For example, the strings "AABC", "ABCA", "BCAA", "CAAB" all represent the same necklace (pictured). In order to get an overview, I store only one of the equivalent strings of...

How to do a case-insensitive string comparison? [duplicate]

c,string,string-comparison,case-insensitive,strcmp
This question already has an answer here: Case Insensitive String comp in C 3 answers I want to do a case-insensitive string comparison. What would be the easiest way to accomplish that? I have the below code which performs a case-sensitive operation. #include <stdio.h> #include <stdlib.h> #include <string.h> int...

Compare if the characters in a string are a subset of a second string in C#

c#,linq,string-comparison
I'm working on a game where I want to check if the characters of a string are contained in another string. Obviously a set would be my first choice but I want to account for duplicates. For example: "met".IsContainedWithin("meet"); => true "meet".IsContainedWithin("met"); => false A multi-set would be nice but...

Why is my if/else statement always skipping to the else

java,swing,if-statement,string-comparison
I have tried reading this every way I can think of and for the life of me I can't figure out why the if/else statement in the actionlistener will never evaluate the if statement to true. This program is meant to open a JFrame with 3 panels. 2 of them...

Check if same image has already been uploaded by comparing BASE64?

php,base64,string-comparison
My question is concerning an idea I had, where I could check if an image has already been uploaded by comparing their base64-encoded strings... Example use-case would be to find duplicates in your database... The operation would be pretty big i guess - first converting the image to base64and then...

Compare strings for equality

c#,string,compare,string-comparison
I want to compare a collection of strings and return the the equal parts until a not equal part occurs. (and remove traling whitespace). example: List<string> strList = new List<string> { "string xyz stop", "string abc stop", "string qrt stop" }; string result = GetEqualName(strList); // This should return "string"...

equalsIgnoreCase vs regionMatches in Java . Which is efficient? [closed]

java,string,string-comparison
I am optimizing a piece of code which uses equalsIgnoreCase and it processes records in millions. Please can anybody give me some insight which one among equalsIgnoreCase and regionMatches is faster and efficient in java.

c++ string comparison in if statement

c++,string-comparison
i have a question about a simple c++ function. This is my cpp file: #include <string> #include <iostream> #include <stdio.h> #include <ros/ros.h> #include <json_prolog/prolog.h> using namespace std; using namespace json_prolog; int main(int argc, char *argv[]) { ros::init(argc, argv, "Knives"); Prolog pl; char M[]="drawer"; cout<<M<<endl; if(strcmp(M,"knife")==0) { string q= "rdfs_individual_of(M, 'http://knowrob.org/kb/knowrob.owl#TableKnife')";...

Java : Getting effected sentence in Google-diff-match-patch

java,regex,string,string-comparison,google-diff-match-patch
I am working on a Java application in which I would like to compare 2 paragraphs and get the sentences which are different in the 2 Strings to be compared. Now I am able to get what is inserted and what is deleted. The problem I am facing is,...

Why does my strcmp fail?

c++,sql,oracle,oracle11g,string-comparison
I am working on an application, where if this certain error message is given, it is ignored: [Oracle][ODBC][Ora]ORA-24338: statement handle not executed My code for comparison is the following: char Sqlstate[10]; long NativeErrorPtr; char MessageText[1024]; long BufferLength=1024; long TextLengthPtr; SQLGetDiagRec(SQL_HANDLE_STMT,sqlc.g_hstmt,1,(SQLCHAR *) Sqlstate,(SQLINTEGER *) &NativeErrorPtr, (SQLCHAR *) MessageText,(SQLSMALLINT) BufferLength,(SQLSMALLINT *) &TextLengthPtr);...

Compare strings in Intersystems Cache Objectscript

string,string-comparison,intersystems-cache,intersystems,objectscript
Given: 2 strings strA, strB I want: To perform a comparison between them and return <0, =0 or >0, in Intersystems Cache ObjectScript. So far: I have found a function in the documentation that fulfills my needs StrComp. Unfortunately, this function is not part of Cache ObjectScript, but from Caché...

String comparison in AngularJS

javascript,json,angularjs,ionic-framework,string-comparison
I'm trying to compare two strings in AngularJS, and I've seen examples online. As I understand it, you can use angular.equals(str1, str2), you can use ===, you can use == if you're sure that both are strings... I've tried all three, but I don't get the result. Something must be...

Java String comparison is not working [closed]

java,string-comparison
public static void main(String[] args) { String a = "Hi I AM "; String a1 = "Hi I AM"; if (a1.equalsIgnoreCase(a)) { System.out.println("equal"); } else { System.out.println("not equal"); } } Why above code is displaying not equal in console?...

Is there a hashing function that can be used in finding similar (not neccesarily equal) strings?

string,hash,string-comparison,string-search,string-hashing
What I need is a hashing function that operates on fixed data sizes, obviously for non security purposes. It needs to map similar strings to similar or equal hashes, in other words small changes in strings should make no or really small changes to hashes. for example: my name is...

Culture-aware string comparison for Umlaute

c#,.net-4.5,string-comparison
I need to compare two strings in German language to check if they are equal and only differ in the use of umlaute. E.g. "Jörg" should be the same as "Joerg". So I tried: var ci = new CultureInfo("de-DE"); int compareResult = ci.CompareInfo.Compare("jörg", "joerg", CompareOptions.IgnoreNonSpace); as well as int compareResult...

Compare two strings in vba excel [Resolved]

excel,vba,excel-vba,compare,string-comparison
I need to compare each cell of the column "Chef" to each cell of the column "nom", so that I can find the right "matricule" and store it in "matt", I have tried this this VBA code: Sub compare() Dim p As Integer Dim q As Integer Dim Nom As...

Why does the Java equals(Object O) method not have a variant which can take a specific object type (e.g. String, Integer, etc) as input?

java,generics,equality,string-comparison,method-signature
I come across problems where I need to compare two strings (or any other object ) for equality/non-equality using Java language. There are two methods on String Object very useful for this purpose viz. compareTo(Object O), which returns a integer result of comparison while other equals(Object o), which returns a...

Is String culture info important for comparison if the user will never modify those strings

c#,string,string-comparison,cultureinfo,hardcode
When comparing hard-coded Strings that the User will see but not modify/change, is the culture info important. I would assume not, but I just want to be safe. Example: static void Main() { string hardString = "IAMHardCodei"; string hardString2 = "IamHardCodei"; //Compare hardString and hardString2, ignoring case, //and then do...

Case sensitive string comparison in Python

python,python-3.x,string-comparison
The following code: if "IAMBIG" > "iambig": print("True") else: print("False") results in: False Since Python is case-sensitive, I understand that checking for equality would result in False in the above if statement. However, I am not sure how string comparison works when checking for - "greater than" (or less than)...

Java searching for a substring URL in a string URL [closed]

java,string,comparison,string-comparison,apache-stringutils
I have a couple of URLs: a. https://iamterribleatthis/a b. https://iamterribleatthis/a/index.html I'm using Apache stringutls to see if 'a' is present in 'b' but I think that the forward slash is failing the comparison. Is there an easier/better way to find if 'a' is present in 'b' including the forward slash?...

Split comma separated list, sort and compare - output the difference - KSH

unix,compare,ksh,string-comparison
I'm working on a problem in KSH, and need to take two comma separated lists and compare them, then output the differences. Example input 1: apple, banana Example input 2: apple, banana, kiwi Output: kiwi I assume I will need to put the lists into arrays and compare each string...

How does PHP compares characters

php,character,string-comparison
Why does "a" > "b" evaluates to false? It is offcourse because of the alphabet. But how does PHP know that a is smaller than b? var_dump("a" > "b"); //boolean false ...

Efficient way to compare strings and get unique value

php,html,arrays,string,string-comparison
I have comma separated n numbers of stings contain numbers like 1,2,3,4,5,6 etc and their length can be n. I have to find numbers those are occurring in all string. Example input: $str1 = '1,2,3,4,5,6,7,8,9'; $str2 = '0,1,4,5,6,7,10,20,23,34,333,78'; $str3 = '5,4,8,3,1,1,1,5,6'; expected output: $result = '1,4,5,6'; I know I can...

SQL Alphanumeric Pattern Matching

sql,tsql,sql-server-2012,string-comparison,string-matching
we ran into an issue where we need to test two varchar numeric strings. So if we had one string like '123456' and '123465'. The character could be swapped at any place in the string. I have no clue what to even Google for help with this, but my hope...

More concise way of setting a counter, incrementing, and returning?

ruby,string-comparison
I'm working on a problem in which I want to compare two strings of equal length, char by char. For each index where the chars differ, I need to increment the counter by 1. Right now I have this: def compute(strand1, strand2) raise ArgumentError, "Sequences are different lengths" unless strand1.length...

Bash: Replace values of a column while retaining line order.

bash,for-loop,sed,string-comparison
I have a file, FILE1, of some 19.000 lines that has the following format: PAAXXXX PAAXXXX 0 0 1 -9 PAAXXXY PAAXXXY 0 0 1 -9 PAAXXYX PAAXXYX 0 0 2 -9 PAAXYXX PAAXYXX 0 0 2 -9 PAAYXXX PAAYXXX 0 0 1 -9 PAAYYXX PAAYYXX 0 0 1 -9...

fastest way to compare string elements with each other

c#,string,performance,string-comparison
I have a list with a lot of strings (>5000) where I have to take the first element and compare it to all following elements. Eg. consider this list of string: { one, two, three, four, five, six, seven, eight, nine, ten }. Now I take one and compare it...

How to compare string to String Array in C#?

c#,compare,user-agent,string-comparison
I have an string; String uA = "Mozilla/5.0 (iPad; CPU OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508 Twitter for iPhone"; String[] a= {"iphone","ipad","ipod"}; It must return ipad because ipad is in the first match ipad at the string. In other case String uA = "Mozilla/5.0 (iPhone/iPad;...

cmake string token inclusion check

string,cmake,string-comparison
In cmake, how can I check if a string token is included in another string? In my case, I would like to know if the name of the compiler contains the string "Clang" (e.g. "clang", "AppleClang", ...). All I could do so far is: if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") ... elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL...

Api's to compare text in java [closed]

java,elasticsearch,string-comparison
I have a web-service in java, which is used by various services to insert data in mongodb. But since data is duplicate, we came with a solution to make a key-value pair of data and check it, if it is already present, before inserting in mongodb. But comparing so many...

Efficient comparison of small integer vectors

c,integer,compare,bit-manipulation,string-comparison
I have small vectors. Each of them is made of 10 integers which are between 0 and 15. This means that every element in a vector can be written using 4 bits. Hence I can concatenate my vector elements and store the whole vector in a single long type (in...

String.Equals vs Sting.Compare vs “==” in Action. Explanation needed

c#,.net,string,string-comparison
Following is the code snippet from a console application - class MyClass { public int GetDay(string data22) { int returnValue = 0; if (string.Compare(data22,"THURSDAY") == 0) // true { returnValue = (int)DayOfWeek.Thursday; } if (data22 == "THURSDAY") //false { returnValue = (int)DayOfWeek.Thursday; } if (string.Equals(data22, "THURSDAY"))//false { returnValue = (int)DayOfWeek.Thursday;...

Comparing char arrays method

c#,arrays,string,char,string-comparison
I've been playing space engineers which has been epic since they added in-game programming, I'm trying to make a gps auto-pilot navigation script and have to get the block positions finding the blocks by name looking for a smaller string within their bigger string name. I wrote this method to...

Why is “ss” equal to the German sharp-s character 'ß'?

c#,.net,windows,string,string-comparison
Coming from this question I'm wondering why ä and ae are different(which makes sense) but ß and ss are treated as equal. I haven't found an answer on SO even if this question seems to be related and even mentions "that ß will compare equal to SS in Germany, or...