I want to compare two strings variable,
which Astring is get from PDF OCR and is a company name
and Bstring is get from excel and also is company name
I want to know if two strings is exactly the same
I used IF function but no idea on how to compare two string
Hi @Andy_Chow
String1 = String2 is the way to compare if 2 strings are exactly the same, spaces and all
hi
check below screen shot
if you want compare with out case sensitive, then use below condition
a.ToLower.Trim = b.ToLower.Trim
Thanks…
I am wondering, if the input of two string is not exactly the same, like string 1 with a few more spaces or comma , can I still compare?
Yes
U can simply remove the spaces and comma
a.ToLower.Replace(" “,”“).Replace(”,“,”“)=b.ToLower.Replace(” “,”“).Replace(”,“,”")
Or u can remove all characters other than alphabets and compare,
System.Text.RegularExpression.Regex.Replace(a,“[^a-zA-Z]”,“”).Equals(System.Text.RegularExpression.Regex.Replace(b,“[^a-zA-Z]”,“”))
thx but I am very new to coding
may i know what is “System.Text.RegularExpression.Regex.Replace” ?
It replaces a string that matches a specific pattern with the given string(replacement string)
From the above ,
Input variable is a
The pattern is [^a-zA-Z] - this keeps only the alphabets(lower case and uppercase)
Replacement string is “” which means nothing. It just replaces the characters other than alphabet’s
For eg:
If variable a=“student123-@sABC”
Output would be studentsABC
If you remove ^ from pattern [^a-zA-Z] ,
Then u will get output as 123-@
OK, thanks a lot!
Main.xaml: Compiler error(s) encountered processing expression “System.Text.RegularExpression.Regex.Replace(address,”[^a-zA-Z]“,”“).Equals(System.Text.RegularExpression.Regex.Replace(string.Concat(address1, address2),”[^a-zA-Z]“,”“))”.
‘RegularExpression’ is not a member of ‘Text’.
‘RegularExpression’ is not a member of ‘Text’.
found this error when i compile
Sorry, it’s RegularExpressions