D digitalbeat Member Licensed User Longtime User Apr 22, 2011 #1 Hi, I've searched the documentation and the threads but I can't seem to find a good example. I want to do a search for a substring where I want a match to occur regardless of the case. For example. String = "I am glad today is Friday" pattern = "friday" I want to "find" and match the above string even if the word is spelled Friday, FRIDAY, or some other combination of upper and lower case. It would seem that CASE_INSENSITIVE being set would do this but I can't find any examples of using it and it keeps giving me errors when I try to use it. Thanks
Hi, I've searched the documentation and the threads but I can't seem to find a good example. I want to do a search for a substring where I want a match to occur regardless of the case. For example. String = "I am glad today is Friday" pattern = "friday" I want to "find" and match the above string even if the word is spelled Friday, FRIDAY, or some other combination of upper and lower case. It would seem that CASE_INSENSITIVE being set would do this but I can't find any examples of using it and it keeps giving me errors when I try to use it. Thanks
R Rioven Active Member Licensed User Longtime User Apr 22, 2011 #2 Sample digitalbeat, Can be this... Code: Dim Stringx, pattern As String Stringx = "I am glad today is Friday" pattern = "friday" Msgbox(Stringx.ToUpperCase.IndexOf(pattern.ToUpperCase),"location") Will display 19 (location from Stringx) (Note: if not found will return -1) Rioven Last edited: Apr 23, 2011 Upvote 0
Sample digitalbeat, Can be this... Code: Dim Stringx, pattern As String Stringx = "I am glad today is Friday" pattern = "friday" Msgbox(Stringx.ToUpperCase.IndexOf(pattern.ToUpperCase),"location") Will display 19 (location from Stringx) (Note: if not found will return -1) Rioven
D digitalbeat Member Licensed User Longtime User Apr 22, 2011 #3 I will give that a try but... Thanks Rioven, I will give that example a try (its a lot cleaner than my working code), but I was originally using regex and matcher and saw that you could set the comparisons to be CASE INSENSITIVE I think and I was wondering if anyone had an example of doing that because every time I try to use the method it just gives me an error. Upvote 0
I will give that a try but... Thanks Rioven, I will give that example a try (its a lot cleaner than my working code), but I was originally using regex and matcher and saw that you could set the comparisons to be CASE INSENSITIVE I think and I was wondering if anyone had an example of doing that because every time I try to use the method it just gives me an error.
R Rioven Active Member Licensed User Longtime User Apr 23, 2011 #4 not simple... Hi digitalbeat, I have just started B4A in a week and I haven't looked at regex matcher and seems not simple. There is a link from B4A Helpviewer HERE Upvote 0
not simple... Hi digitalbeat, I have just started B4A in a week and I haven't looked at regex matcher and seems not simple. There is a link from B4A Helpviewer HERE
Erel B4X founder Staff member Licensed User Longtime User Apr 23, 2011 #5 Have you read this tutorial: Regular expressions tutorial It explains the usage of CASE_INSENSITIVE. Upvote 0
D digitalbeat Member Licensed User Longtime User Apr 24, 2011 #6 Hi Erel; Yes I did read it but it didn't give an example of using CASE INSENSITIVE which is what I was asking about. I use REGEX to match a SINGLE LETTER occurrence in a string i.e (a) or (A) with this expression: pattern = "^\(([A-Za-z])\)" m1 = Regex.Matcher(pattern, istr) and it appears to work. If I code m1 = Regex.CASE_INSENSITIVE.Matcher(pattern, istr) then it fails to compile so I am missing something that I think a simple example of its usage (which isnt in the tutorial) would explain. The CASE INSENSITIVE would simplify things if I understood how to make it work. Thanks Upvote 0
Hi Erel; Yes I did read it but it didn't give an example of using CASE INSENSITIVE which is what I was asking about. I use REGEX to match a SINGLE LETTER occurrence in a string i.e (a) or (A) with this expression: pattern = "^\(([A-Za-z])\)" m1 = Regex.Matcher(pattern, istr) and it appears to work. If I code m1 = Regex.CASE_INSENSITIVE.Matcher(pattern, istr) then it fails to compile so I am missing something that I think a simple example of its usage (which isnt in the tutorial) would explain. The CASE INSENSITIVE would simplify things if I understood how to make it work. Thanks
Erel B4X founder Staff member Licensed User Longtime User Apr 24, 2011 #7 You should pass the CASE_INSENSITIVE as the options parameter: Code: m1 = Regex.Matcher2(patter, Regex.CASE_INSENSITIVE, istr) 'Matcher2 not Matcher Upvote 0
You should pass the CASE_INSENSITIVE as the options parameter: Code: m1 = Regex.Matcher2(patter, Regex.CASE_INSENSITIVE, istr) 'Matcher2 not Matcher
D digitalbeat Member Licensed User Longtime User May 4, 2011 #8 Thanks Erel; Your example did the trick! Upvote 0