Menu
  • HOME
  • TAGS

cmake string token inclusion check

string,cmake,string-comparison

if(<variable|string> MATCHES regex) will probably be what you're looking for. In this particular case (assuming you're doing the same thing inside the block for Clang and AppleClang) then you can replace: if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") ... elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") ... with: if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") ...

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

c,string,string-comparison,case-insensitive,strcmp

If you can afford deviating a little from strict C standard, you can make use of strcasecmp(). It is a POSIX API. Otherwise, you always have the option to convert the strings to a certain case (UPPER or lower) and then perform the normal comparison using strcmp()....

Comparing String with Integer in javascript

javascript,type-conversion,string-comparison

When the runtime attempts to convert 'sachin' to a number, it will fail and end up as NaN. That special constant results in false for any comparison to any other numeric value. The NaN constant ("Not A Number") is not equal to any other value, nor is it less than...

Api's to compare text in java [closed]

java,elasticsearch,string-comparison

If the text is exactly the same you could hash it and just compare hashes. If you don't have too many entries sha1 should suffice. As JonasCz said, please update you question so we know if the texts are exactly the same (my solution could work) or similar (my solution...

How to compare strings at C# like in SQL server case insensitive and accent insensitive [duplicate]

c#,string-comparison,case-insensitive,accent-insensitive

This compares all those strings as equal: string.Compare(s1,s2, CultureInfo.InvariantCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase) ...

Ignore last character when comparing strings

tsql,sql-server-2012,string-comparison

Since the length of sub-string after - is either 3 or 4, you just only fetch 3 characters after -. Here is code snippet LEFT(@a, CHARINDEX('-', @a) + 3) = LEFT(@b, CHARINDEX('-', @b) + 3) ...

Is there a way in python to compare strings for unique character [closed]

python,string-comparison

Assuming Benoît Latinier's interpretation of your question is right (which, it looks like it is), then there will be some cases where a unique letter can't be found, and in these cases you might throw an exception: def unique_chars(words): taken = set() uniques = [] for word in words: for...

Compare strings for equality

c#,string,compare,string-comparison

You can Zip two strings together, take the pairs that are equal, and then create a string of those characters. public static string LargestCommonPrefix(string first, string second) { return new string(first.Zip(second, Tuple.Create) .TakeWhile(pair => pair.Item1 == pair.Item2) .Select(pair => pair.Item1) .ToArray()); } Once you've solved the problem for the case...

Compare results of 2 split strings?

c#,string,split,string-comparison

With all the strings splittend and stored in arrays (oldItems and newItems), and using System.Linq. Try this: var changedResults = newItems.Where(x => !oldItems.Any(y => x == y)); With this you will get a IEnumerable with all the string in newItems which no appear in oldItems array. If you want to...

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

java,swing,if-statement,string-comparison

arg0.getSource() will return a reference to the object which triggered the event, in this case, the JButton. Instead, you should be able to use ActionEvent#getActionCommand instead. String cmd = agr0.getActionCommmand(); //... If you're using Java 7+, you may find it easier to use a switch statement... switch (cmd) { case...

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

unix,compare,ksh,string-comparison

looking for complement of two lists: $ a="1,2,3,4,5" $ b="2,3,4,5,6" $ echo $a,$b | tr , "\n" | sort | uniq -u 1 6 or, the same, but passing lists separetely (e.g. if you need different preprocessing): $ sort <(echo $a | tr , "\n") <(echo $b | tr ,...

Java String comparison is not working [closed]

java,string-comparison

The first String has an additional space at the end, so it's not equal to the second String.

iOS - comparing app versions

ios,objective-c,version,string-comparison,info.plist

You can compare numeric version numbers using natural sort order (which will consider 1.10 to come after 1.1, unlike lexicographic sort order) as follows: BOOL isNewer = ([currentVersion compare:oldVersion options:NSNumericSearch] == NSOrderedDescending) ...

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

java,regex,string,string-comparison,google-diff-match-patch

After extensive reconsideration I think this is not a case for a regular expression . The same changes my appear in several lines so you have to check your input line by line like this: //-------------------------Example Strings--------------------------------------------- private static String oldText = "I yoyo am also working on a \n...

Case sensitive string comparison in Python

python,python-3.x,string-comparison

Python 3 compares strings as sequences of unicode characters. Since the unicode number for character I is U+0049 and for character i is U+0069, it is natural that the comparison "I..." > "i..." returns False. I general latin small letters have numbers larger than large letters, which will make capitalized...

String comparison in AngularJS

javascript,json,angularjs,ionic-framework,string-comparison

You are iterating over wrong node:) for(var i=0;i<$rootScope.items.length;i++) { alert("Inside for loop"); if (name === $rootScope.items[i].names) // you iterate over items, not names, which it an Json property inside item { alert("If condition satisfied"); } } ...

Select statement returns nothing when column collation SQL_Latin1_General_CP1_CI_AS in T-sql

sql-server,collation,string-comparison

In T/SQL the string constant 'БHО' is an ANSI string, and 'Б' is not available so you'll get the question marks that @EduardUta queried. You need to work with Unicode strings, using the N prefix for string constants and nvarchar. Try this; SELECT Veri from tblTest where CAST(Veri COLLATE SQL_Latin1_General_CP1_CI_AS...

How to compare strings in javascript ignoring special characters

javascript,unicode,string-comparison

You can convert them and then match them, let me if my example is clear :) var stringInTheSystem = ['aaaa','bbbb'];// Array of string in your system; var term = 'áaaa';// the word you want to compare it; term = term.replace(/á/g, "a"); term = term.replace(/é/g, "e"); term = term.replace(/í/g, "i"); term...

comparing string with accents in php

php,string,string-comparison

As usual when dealing with charset problems, you need to be extra careful about the character counts between multibyte strings and plain ASCII strings. Your biggest problem here is that you remove some pre-defined characters from the cleaned string, rendering character count coherence between the sanitized string and the original,...

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

c#,.net,string,string-comparison

Why does the first comparison (string.compare) work and the other two comparison methods does not work in THIS PARTICULAR CASE There are invisible characters (particularly, a Left-to-Right mark (Thanks @MatthewWatson)) in your code. You can view them with any hex editor: This is over-looked by string.Compare, while it isn't...

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

Because equals() is declared in Object and compareTo(T foo) is defined in Comparable<T>. Before generics the issue was the same with Comparable, compareTo taking an Object argument, but since there's no "Equalable" interface there was no place to stick the generic parameter....

Identical Strings in PHP not matching [duplicate]

php,regex,string,string-comparison

Here is your problem: if ($current == null || $current = "") { // ^ now `$current` is "", an empty string You assign a new value to $current, an empty string. You probably want something like: if ($current == null || $current == "") { // ^^ now you...

Compare lists of strings regarding the suffixes of their respective elements

python,performance,list,string-comparison

Make a set if the prefixes, check if the prefix set is a subset of the prefixes of each element in your sublists, if it is then check if all suffixes are the same. st = {s[0] for s in myList} l = [] for ind, sub in enumerate(myListOfList): k...

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

bash,for-loop,sed,string-comparison

In awk, using ARGIND awk 'ARGIND~"1|2"{a[$1]=ARGIND;next}a[$1]{$NF=a[$1]}1' FILE2 FILE3 FILE1 PAAXXXX PAAXXXX 0 0 1 -9 PAAXXXY PAAXXXY 0 0 1 -9 PAAXXYX PAAXXYX 0 0 2 1 PAAXYXX PAAXYXX 0 0 2 1 PAAYXXX PAAYXXX 0 0 1 1 PAAYYXX PAAYYXX 0 0 1 -9 PAAYYYX PAAYYYX 0 0 2...

C Custom Binary Search not following Multiple Of Element Size rule and crashes

c,crash,binary-search,string-comparison

You appear to be trying to pass a pointer as an integer (see how ArrayPointer is declared as an int but you are casting it to a char **. You are then manipulating the integer with the binary search. This is why you are getting whacky results. Instead, you want...

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

c#,.net,windows,string,string-comparison

If you look at the Ä page, you'll see that not always Ä is a replacement for Æ (or ae), and it is still used in various languages. The letter ß instead: While the letter "ß" has been used in other languages, it is now only used in German. However,...

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

ruby,string-comparison

Probably the simplest answer is to just count the differences: strand1.chars.zip(strand2.chars).count{|a, b| a != b} ...

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

c#,string,string-comparison,cultureinfo,hardcode

The general recommendation for string comparisons when they are "programmatic only strings" (i.e. as you specified they are not usable or editable by the user directly is the: StringComparison.Ordinal[IgnoreCase]. See this SO post (of which this is probably a duplicate): Which is generally best to use -- StringComparison.OrdinalIgnoreCase or StringComparison.InvariantCultureIgnoreCase?...

Need String Comparison 's solution for Partial String Comparison in Python

python,string,algorithm,python-2.7,string-comparison

Since you want to compare only stem or "root word" of a given word, I suggest using some stemming algorithm. Stemming algorithms attempt to automatically remove suffixes (and in some cases prefixes) in order to find the "root word" or stem of a given word. This is useful in various...

Removing similar lines from two files

powershell,text-files,string-comparison

You can remove the contents of file B from file A with something like this: $ref = Get-Content 'C:\path\to\fileB.txt' (Get-Content 'C:\path\to\fileA.txt') | ? { $ref -notcontains $_ } | Set-Content 'C:\path\to\fileA.txt' ...

Comparing strings in foreach loop doesn't return correct array

php,arrays,foreach,string-comparison

You need to replace your if with this: if (!empty($over_title) && ($bibLvl=='a')) { foreach ($auth2_role as $key=>$field){ if ($field == $auth_role) { $authdisplay[] = $author2[$key]; } } return $authdisplay; } Result: Array ( [0] => Smith [1] => Jones ) ...

Efficient way to compare strings and get unique value

php,html,arrays,string,string-comparison

Try $result = array_unique(array_intersect(explode(',', $str1), explode(',', $str2), explode(',', $str3))); Edit: Well the point is to explode strings to arrays, then get intersect and finally pick unique values....

Buttons text to string

android,string-comparison

Change this: if (word == word2) { with this: if(word.equals(word2)) { You can't compare String with ==...

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

php,base64,string-comparison

Here's a function that can help you compare files faster. Aside from checking an obvious thing like file size, you can play more with comparing binary chunks. For example, check the last n bytes as well as a chunk of a random offset. I used checksum comparison as a last...

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

mysql,prepared-statement,string-comparison

I have solved my problem by trying my query string in my phpMyAdmin sql query section of my database. And I have relized when I build my query like this: $statement = $db->prepare("SELECT * FROM myTable WHERE (creationDate > $startingDate) = 1 ORDER BY creationDate DESC "); It becomes: SELECT...

Culture-aware string comparison for Umlaute

c#,.net-4.5,string-comparison

I had the same issue and found no other solution then replacing them e.g. by a extension. As far as i know there is no "direct" solution for this. public static string ReplaceUmlaute(this string s) { return s.Replace("ä", "ae").Replace("ö", "oe").Replace("ü", "ue").Replace("Ä", "AE").Replace("Ö", "OE").Replace("Ü", "UE"); } Result: int compareResult = String.Compare("jörg".ReplaceUmlaute(),...

fastest way to compare two columns of strings in C#

c#,performance,string-comparison

If the speed is all your concern you can use Dictionary instead of Lists/Arrays when fetching the data // Key (string) - String value // Value (int) - repeat count Dictionary<String, int> values = new Dictionary<String, int>(); // Fill values: adding up v1, removing v2 using (IDataReader reader = myQuery.ExecuteReader())...

How does PHP compares characters

php,character,string-comparison

But how does php knows that "a" is smaller then "b"? PHP takes the ASCII values of the characters and compare them. So this is how PHP decides which character is "smaller" than the other one. ASCII table: So in your example: a = 97 //'97' is the ASCII...

Comparing char arrays method

c#,arrays,string,char,string-comparison

This is simple with .Contains() which returns a bool. text.Contains(wordInText); ...

Efficient comparison of small integer vectors

c,integer,compare,bit-manipulation,string-comparison

It's possible to do this using bit-manipulation. Space your values out so that each takes up 5 bits, with 4 bits for the value and an empty 0 in the most significant position as a kind of spacing bit. Placing a spacing bit between each value stops borrows/carries from propagating...

fastest way to compare string elements with each other

c#,string,performance,string-comparison

The amount of downvotes is crazy but oh well... I found the reason for my performance issue / bottleneck thanks to the comments. The second for loop inside StartSimilarityCheck() iterates over all entries, which in itself is no problem but when viewed under performance issues and efficient, is bad. The...

Compare two strings in vba excel [Resolved]

excel,vba,excel-vba,compare,string-comparison

Problem is in InStr Function -> https://msdn.microsoft.com/en-us/library/8460tsh1%28v=vs.90%29.aspx Temps = InStr(1, UCase(Nom), UCase(Nomchercher), vbTextCompare) You search UCase(Nomchercher) in UCase(Nom) You always find Nom = "" in all data in column Nomchercher This will works better: Temps = InStr(1, UCase(Nomchercher), UCase(Nom), vbTextCompare) Edit: (faster compare) Sub FasterCompare() Dim ColMatricule As Integer Dim...

Why does my strcmp fail?

c++,sql,oracle,oracle11g,string-comparison

My problem must have been that it is not NULL-terminated. I followed ibre5041's advice and used if((strncmp(msg, oracleMsg, 55))== 0). This only compares the first 55 characters, which avoids the non NULL-terminated issue.

Reading foreign characters

string,r,encoding,character-encoding,string-comparison

EDIT: It seems that the file you provided uses a different encoding than your system's native one. An (experimental) encoding detection done by the stri_enc_detect function from the stringi package gives: library('stringi') PlayerDataRaw <- stri_read_raw('~/Desktop/PLAYERS.csv') stri_enc_detect(PlayerDataRaw) ## [[1]] ## [[1]]$Encoding ## [1] "ISO-8859-1" "ISO-8859-2" "ISO-8859-9" "IBM424_rtl" ## ## [[1]]$Language ##...

Normalize strings that represent (combinatorical) necklaces [closed]

python,combinatorics,string-comparison,string-matching

If I understand you correctly you first need to construct all circular permutations of the input sequence and then determine the (lexicographically) smallest element. That is the root of your symbol loop. Try this: def normalized(s): L = [s[i:] + s[:i] for i in range(len(s))] return sorted(L)[0] This code works...

If else in JSP (switch case) [duplicate]

java,string-comparison

This is one of the first problems I ever ran into while learning Java: the quandary of == vs equals. Fortunately, once you understand why they're different, it's easy to use them properly. Whenever you're dealing with objects (as you are in this case), the == operator is used to...

Comparing String with It's Reference by “==” [duplicate]

java,string,string-comparison

== Compares the reference of the string and is unreliable to use for value comparison. Your s1=="String1" I would imagine is true because you're comparing two literals, compared to the s2 comparison of a new String object compared to a literal.

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 would use an SSIS Lookup task using the Partial Cache option: https://msdn.microsoft.com/en-us/library/ms137820.aspx This will execute the specified SQL statement row-by-row. The SQL statement design would essentially be what you have coded in your question - getting SQL to do the complex join requirement. For performance reasons, I usually have...

MySQL String Comparison with Wildcards

mysql,wildcard,string-comparison

Use a regular expression: WHERE Description RLIKE '[[:<:]]apple[[:>:]]' [[:<:]] matches the beginning of a word, [[:>:]] matches the end of a word. See the documentation for all the regexp operators supported by MySQL...

SQL Alphanumeric Pattern Matching

sql,tsql,sql-server-2012,string-comparison,string-matching

You might google "Levenshtein distance". Here's a potentially relevant answer: Levenshtein distance in T-SQL...

Why doesn't t != “Q” kill while loop when gets(t) gets input “Q” from command line?

c,character,string-comparison,gets

There are several things wrong with your program. char t[1] = "a"; A string consists of a sequence of characters terminated by a null character '\0'. You haven't left enough room in t to hold the character 'a' plus the terminating '\0'. Due to a special rule, this stores just...

c++ string comparison in if statement

c++,string-comparison

try this: std::string M; cin >> M; replace lines like this: if(strcmp(M,"drawer")==0) with this: if (M == "drawer" ) ...

Same strings are different

java,android,character-encoding,string-comparison,non-ascii-chars

The difference in the printed arrays is -61, -79 versus -47, -127 as the representation of “ñ”. The negative numbers are apparently what you get when you print bytes interpreted as signed numbers (the first bit being the sign bit). Treating them as unsigned, as bytes in character representations should...

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

string,hash,string-comparison,string-search,string-hashing

There is no reliable way of achieving this. This is due to the pigeonhole principle; there are far fewer ways that two short strings can be "close" than two long strings. However, there is the concept of fuzzy hashing, which might get you part of the way there....

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

c#,linq,string-comparison

This works for me: public static bool IsContainedWithin(this string @this, string container) { var lookup = container.ToLookup(c => c); return @this.ToLookup(c => c).All(c => lookup[c.Key].Count() >= c.Count()); } I tested it like this: var tests = new [] { "met".IsContainedWithin("meet"), "meet".IsContainedWithin("met"), "git".IsContainedWithin("light"), "pall".IsContainedWithin("lamp"), }; I got these results: True False...

how to process big file with comparison of each line in that file with remaining all lines in same file?

string-comparison,opencsv,file-processing

It is taking a long time because it looks like you are reading the file a huge amount of times. You first read the file into the lines List, then for every entry you read it again, then inside that you read it again!. Instead of doing this, read the...

How to compare string to String Array in C#?

c#,compare,user-agent,string-comparison

So you want the word within the array which occurs earliest in the target string? That sounds like you might want something like: return array.Select(word => new { word, index = target.IndexOf(word) }) .Where(pair => pair.index != -1) .OrderBy(pair => pair.index) .Select(pair => pair.word) .FirstOrDefault(); Those steps in detail: Project...

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

java,string,string-comparison

If you check the implementation of equalsIgnoreCase, it just relies on regionMatches: public boolean equalsIgnoreCase(String anotherString) { return (this == anotherString) ? true : (anotherString != null) && (anotherString.value.length == value.length) && regionMatches(true, 0, anotherString, 0, value.length); } Therefore, if you do not need to check the length of both...

How does the comparison in Strings work? [duplicate]

java,string,trim,string-comparison

trim() returns a copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space. in the first case the answer is true no surprise about that because the references are equal in the second case there are no...

String Comparison Using Nested Loops

java,loops,comparison,string-comparison

Since you are working on an exercise, I wouldn't fix your code, but help you fix it yourself. First, some basics: in Java you use charAt(i) to access an individual character. For example, char ch = Text1.charAt(3); gets you the forth character from the beginning of the string (indexes are...

Compare strings in Intersystems Cache Objectscript

string,string-comparison,intersystems-cache,intersystems,objectscript

It's a bit unclear exactly what you want this string comparison to do, but it appears that you're looking for either the follows ] or sorts after ]] operator. Docs (taken from here): The binary follows operator (]) tests whether the characters in the left operand come after the characters...

Comparing two dates in JSP

java,jsp,date,string-comparison

The compiler is expecting something like boolean flag = to the left of the line (reportVO.getEndDate().getYear() == 9999 && reportVO.getEndDate().getMonth() == 12 && reportVO.getEndDate().getDate() == 31); Hence the error about completing the Assignment Operator Expression.

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

java,string,comparison,string-comparison,apache-stringutils

String a = "https://iamterribleatthis/a"; String b = "https://iamterribleatthis/a/index.html"; System.out.println(b.contains(a)); ...

compare NSInteger with sorted NSIntegerArray objectAtIndex

ios,objective-c,string-comparison

i is an index that iterates through your array, so you don't need all of the separate if statements. Note that I have assumed that highscoreindex actually contains NSNumbers because you can't store NSIntegers in an array @property (nonatomic) NSMutableArray *highscoreindex; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; self.highscoreindex = [defaults objectForKey:@"highscore"];...

Newbie to Java, wondering about if statements and strings that are read by Scanner

java,java.util.scanner,conditional-statements,string-comparison

First off, a class is always capitalized so public class test should be public class Test. You need to compare explicitely with a String. As one is defined nowhere, your code will not work. replace: if (password.equals(one)) with if (password.equals("one")) and you are good to go. Instead, you could also...

How to compare exact same string but with different charCodes in Javascript

javascript,string,compare,string-comparison

After the help from Wa Kai and nomve I found out that there were those 8203 charcodes which I could get rid of by using following code: lt.replace(/\u200B/g,'') Just to make shure you can also use this: lt.replace(/[\u200B-\u200D\uFEFF]/g, ''); Which will remove: U+200B zero width space U+200C zero width non-joiner...