G GuyBooth Active Member Licensed User Longtime User Aug 11, 2022 #1 I'm trying to return the result of searching a string for 's. I have tried the following - among others - which all return false B4X: MyString.contains("'s") MyString.contains($"${Chr(39)}s"$) MyString.contains($"'s"$) What am I missing?
I'm trying to return the result of searching a string for 's. I have tried the following - among others - which all return false B4X: MyString.contains("'s") MyString.contains($"${Chr(39)}s"$) MyString.contains($"'s"$) What am I missing?
Jeffrey Cameron Well-Known Member Licensed User Longtime User Aug 11, 2022 #2 I don't know how the contains method is implemented, if it's based off a regex you might try escaping the single-quote with a backslash, e.g. B4X: MyString.Contains("\'s") If that still fails, then I'd be willing to bet the character you're comparing against in the string isn't actually Chr(39). Upvote 0
I don't know how the contains method is implemented, if it's based off a regex you might try escaping the single-quote with a backslash, e.g. B4X: MyString.Contains("\'s") If that still fails, then I'd be willing to bet the character you're comparing against in the string isn't actually Chr(39).
G GuyBooth Active Member Licensed User Longtime User Aug 11, 2022 #3 Jeffrey Cameron said: I don't know how the contains method is implemented, if it's based off a regex you might try escaping the single-quote with a backslash, e.g. B4X: MyString.Contains("\'s") If that still fails, then I'd be willing to bet the character you're comparing against in the string isn't actually Chr(39). Click to expand... I actually don't care about "chr(39)". I'm simply trying to find if my string contains the characters 's And no, B4X: MyString.contains("\'s") sadly doesn't work. Thanks for the thought though Upvote 0
Jeffrey Cameron said: I don't know how the contains method is implemented, if it's based off a regex you might try escaping the single-quote with a backslash, e.g. B4X: MyString.Contains("\'s") If that still fails, then I'd be willing to bet the character you're comparing against in the string isn't actually Chr(39). Click to expand... I actually don't care about "chr(39)". I'm simply trying to find if my string contains the characters 's And no, B4X: MyString.contains("\'s") sadly doesn't work. Thanks for the thought though
M Mahares Expert Licensed User Longtime User Aug 11, 2022 #4 I tried this and it retirned true: B4X: Dim mystring As String = "it's actually useful" Log(mystring.contains("'s")) 'returns true Upvote 0
I tried this and it retirned true: B4X: Dim mystring As String = "it's actually useful" Log(mystring.contains("'s")) 'returns true
G GuyBooth Active Member Licensed User Longtime User Aug 11, 2022 #5 Thanks for the sanity check Mahares. Seems I had previously chopped an extra letter off the end of the word All fixed. Upvote 0
Thanks for the sanity check Mahares. Seems I had previously chopped an extra letter off the end of the word All fixed.