B4J Question [SOLVED] How To Find/Match A Character in a String

cklester

Well-Known Member
Licensed User
How would I do something like this:

B4X:
dim myString as String = "DONKEYKONG"
dim pos as Int = myString.CharAt(0) is in "ABCDEF"

Basically, does the first character of my string exist in the given comparison string?

I tried searching for a find() or match() but was unsuccessful.


I found this way:

B4X:
    Do While "ABCDEFabcdef".Contains(confirm_code.CharAt(0))
        confirm_code = DB.GenerateSessionID
    Loop

The interesting reason why I had to do this: when sending a URL like

B4X:
https://mysite.com/confirm?code=jh938hfkajshf9s8dfhhlakjghldk

if the code starts with A thru F (including lowercase) and a number, it gets converted into a weird character in the email.

1611605702192.png


The raw text of that email is this:

B4X:
Please click this link to confirm this request: http://127.0.0.1:51042/confirm?code=b4A87FDRqYyXgCRqaQRPR9oh0gsHk1BeP

Because it starts with a 'b' and a number, the email thinks it's some hex or other encoding... I think.

I did a search for this on the Internet and couldn't find anything about it, although it looks like I could change the text encoding header of the email from UTF-8. I'm not sure if that's the issue or not, but I'm basically just making sure those codes don't start with A thru F!

If anybody has any other ideas, I'm open to hearing them.
 
Top