string-matching

Partial cell(or string) match in excel macro

£可爱£侵袭症+ 提交于 2019-12-04 03:27:55
问题 I am new to VBA and I would like to do a partial string (or cell) match between two sheets. An example of Name1 would be "IT executive Sally Lim" An example of Name2 would be "Sally Lim" Name1 = Sheets("Work").Cells(RowName1, ColName1) Name2 = Sheets("Roster").Cells(RowName2, ColName2) 'This condition doesn't work If Name1 = "*" & Name2 & "*" Then 'The "Name2" comes out with a compile error: Invalid Qualifier Name2.Font.Strikethrough Exit Do Else End If However, it is not working. When I run

C#: How to Delete the matching substring between 2 strings?

眉间皱痕 提交于 2019-12-04 03:14:46
问题 If I have two strings .. say string1="Hello Dear c'Lint" and string2="Dear" .. I want to Compare the strings first and delete the matching substring .. the result of the above string pairs is: "Hello c'Lint" (i.e, two spaces between "Hello" and "c'Lint" ) for simplicity, we'll assume that string2 will be the sub-set of string1 .. (i mean string1 will contain string2).. 回答1: Do this only: string string1 = textBox1.Text; string string2 = textBox2.Text; string string1_part1=string1.Substring(0,

Possible bug in VB.NET 'Like' operator?

≡放荡痞女 提交于 2019-12-04 03:05:27
Why is it that the following evaluates as True ? Dim result = "b" Like "*a*b" Thanks. EDIT: To generalize this a bit, the following returns True : "String1" Like "*AnyText1*AnyText2*AnyText???******????*String1" VBA works correctly, returning False . PowerShell works correctly, returning False : PS C:\Users\XXX> "b" -Like "*a*b" False EDIT2: The link to the bug report: https://connect.microsoft.com/VisualStudio/feedback/details/748415/a-bug-in-net-like-operator I decided, for fun, to open up ilspy to debug this :-) in this method; private static void MatchAsterisk(string Source, int

php string matching with wildcard *?

怎甘沉沦 提交于 2019-12-03 14:33:38
问题 I want to give the possibility to match string with wildcard * . Example $mystring = 'dir/folder1/file'; $pattern = 'dir/*/file'; stringMatchWithWildcard($mystring,$pattern); //> Returns true Example 2: $mystring = 'string bl#abla;y'; $pattern = 'string*y'; stringMatchWithWildcard($mystring,$pattern); //> Returns true I thought something like: function stringMatch($source,$pattern) { $pattern = preg_quote($pattern,'/'); $pattern = str_replace( '\*' , '.*?', $pattern); //> This is the

How to compare and convert emoji characters in C#

二次信任 提交于 2019-12-03 13:40:01
I am trying to figure out how to check if a string contains a specfic emoji. For example, look at the following two emoji: Bicyclist: http://unicode.org/emoji/charts/full-emoji-list.html#1f6b4 US Flag: http://unicode.org/emoji/charts/full-emoji-list.html#1f1fa_1f1f8 Bicyclist is U+1F6B4 , and the US flag is U+1F1FA U+1F1F8 . However, the emoji to check for are provided to me in an array like this, with just the numerical value in strings: var checkFor = new string[] {"1F6B4","1F1FA-1F1F8"}; How can I convert those array values into actual unicode characters and check to see if a string

Which algorithm is being used in Android's spell checker?

亡梦爱人 提交于 2019-12-03 12:44:53
问题 I am doing some research on string matching algorithms. One of the most usable I came across is the one my cellphone uses (android 2.3.4 on SE xPeria neo v). As seen in the screenshot, I pressed the characters jiw which are near the ones I wanted and it suggested correctly. It seems like the algorithm is similar to levenstein distance (distance between my input and the dictionary). Somehow the near characters have some value in the string-matching. Any idea about the algorithm being used? 回答1

Damerau–Levenshtein distance (Edit Distance with Transposition) c implementation

风格不统一 提交于 2019-12-03 11:42:49
I implemented the Damerau–Levenshtein distance in c++ but it does not give correct o/p for the input (pantera,aorta) the correct o/p is 4 but my code gives 5..... int editdist(string s,string t,int n,int m) { int d1,d2,d3,cost; int i,j; for(i=0;i<=n;i++) { for(j=0;j<=m;j++) { if(s[i+1]==t[j+1]) cost=0; else cost=1; d1=d[i][j+1]+1; d2=d[i+1][j]+1; d3=d[i][j]+cost; d[i+1][j+1]=minimum(d1,d2,d3); if(i>0 && j>0 && s[i+1]==t[j] && s[i]==t[j+1] ) //transposition { d[i+1][j+1]=min(d[i+1][j+1],d[i-1][j-1]+cost); } } } return d[n+1][m+1]; } I don't see any errors. Can someone find a problem with the

One of strings in array to match an expression

和自甴很熟 提交于 2019-12-03 10:13:04
The Problem: I have an array of promises which is resolved to an array of strings . Now the test should pass if at least one of the strings matches a regular expression. Currently, I solve it using simple string concatenation: protractor.promise.all([text1, text2, text3]).then(function (values) { expect(values[0] + values[1] + values[2]).toMatch(/expression/); }); Obviously, this does not scale well and is not particularly readable. The Question: Is is possible to solve it using a custom jasmine matcher , or jasmine.any() or custom asymmetric equality tester ? You could simply use map to get a

What is the best algorithm for matching two string containing less than 10 words in latin script

你说的曾经没有我的故事 提交于 2019-12-03 10:12:04
问题 I'm comparing song titles, using Latin script (although not always), my aim is an algorithm that gives a high score if the two song titles seem to be the same same title and a very low score if they have nothing in common. Now I already had to code (Java) to write this using Lucene and a RAMDirectory - however using Lucene simply to compare two strings is too heavyweight and consequently too slow. I've now moved to using https://github.com/nickmancol/simmetrics which has many nice algorithms

Pandas text matching like SQL's LIKE?

不羁的心 提交于 2019-12-03 09:34:34
Is there a way to do something similar to SQL's LIKE syntax on a pandas text DataFrame column, such that it returns a list of indices, or a list of booleans that can be used for indexing the dataframe? For example, I would like to be able to match all rows where the column starts with 'prefix_', similar to WHERE <col> LIKE prefix_% in SQL. You can use the Series method str.startswith (which takes a regex): In [11]: s = pd.Series(['aa', 'ab', 'ca', np.nan]) In [12]: s.str.startswith('a', na=False) Out[12]: 0 True 1 True 2 False 3 False dtype: bool You can also do the same with str.contains