Just starting out? Need help? Post your questions and find answers here.
Rjevsky
User
Posts: 23 Joined: Tue Jul 18, 2017 3:41 pm
Post
by Rjevsky » Sat Jun 22, 2019 6:42 pm
Hello to all! I have a problem with the code.
Code: Select all
If CreateRegularExpression(0, "(.+?)\|(.+?)")
If ExamineRegularExpression(0, " :evil: | :twisted: ")
While NextRegularExpressionMatch(0)
RegularExpressionGroup(0, 1)
If OpenFile(0, "test.txt")
FileSeek(0, Lof(0))
WriteStringN(0, RegularExpressionGroup(0, 1)+RegularExpressionGroup(0, 1))
WriteStringN(0, " :evil: :twisted: ")
CloseFile(0)
EndIf
Wend
EndIf
Else
Debug RegularExpressionError()
EndIf
Replace this smiles to emoji from here:
https://getemoji.com like this:
(I can't insert normal code due to forum problems)
Result:
Why are emoji in string #1 lost?
Last edited by
Rjevsky on Sat Jun 22, 2019 8:29 pm, edited 1 time in total.
Little John
Addict
Posts: 4519 Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany
Post
by Little John » Sat Jun 22, 2019 7:21 pm
Code: Select all
If CreateRegularExpression(0, "(.+?)\|(.+?)")
If ExamineRegularExpression(0, " :evil: | :twisted: ")
While NextRegularExpressionMatch(0)
--> RegularExpressionGroup(0, 1) <--- remove this line
If OpenFile(0, "test.txt")
FileSeek(0, Lof(0))
WriteStringN(0, RegularExpressionGroup(0, 1)+RegularExpressionGroup(0, 1))
WriteStringN(0, " :evil: :twisted: ")
CloseFile(0)
EndIf
Wend
EndIf
Else
Debug RegularExpressionError()
EndIf
What is the purpose of the marked line?
My suggestion: Remove it and see whether the code then works as desired.
404 Not Found.
Rjevsky
User
Posts: 23 Joined: Tue Jul 18, 2017 3:41 pm
Post
by Rjevsky » Sat Jun 22, 2019 8:33 pm
Little John wrote:
What is the purpose of the marked line?
My suggestion: Remove it and see whether the code then works as desired.
Yes, this is an extra line, but it does not solve the problem.
Little John wrote:
404 Not Found.
Fixed.
#NULL
Addict
Posts: 1440 Joined: Thu Aug 30, 2007 11:54 pm
Location: right here
Post
by #NULL » Sat Jun 22, 2019 9:35 pm
Somehow it doesn't work, but I don't know if that is supported and/or if there is a problem with multibyte sequences. The ape is 4 bytes in a pb utf-16 string.
I used this one (replace x in code):
https://emojipedia.org/hear-no-evil-monkey/
Code: Select all
Debug "test:" + "x" ; (make sure you debug window font can display it)
If CreateRegularExpression(0, "(x)")
If ExamineRegularExpression(0, "x")
While NextRegularExpressionMatch(0)
Debug "group:" + RegularExpressionGroup(0, 1)
Wend
EndIf
Else
Debug RegularExpressionError()
EndIf
Derren
Enthusiast
Posts: 313 Joined: Sat Jul 23, 2011 1:13 am
Location: Germany
Post
by Derren » Sat Jun 22, 2019 10:58 pm
I don't know what your code is supposed to do. it doesn't put both emojis into the file.
But the first one is put into the file correctly.
And if I switch it for the monkey that #NULL used, it works as well.
#NULL
Addict
Posts: 1440 Joined: Thu Aug 30, 2007 11:54 pm
Location: right here
Post
by #NULL » Sun Jun 23, 2019 6:19 am
Code: Select all
s.s = Space(2)
PokeQ(@s, 3729381437)
Debug "test:" + s ; (make sure you debug window font can display it)
If CreateRegularExpression(0, s+"abc")
If ExamineRegularExpression(0, s+"abc")
While NextRegularExpressionMatch(0)
Debug "match:" + RegularExpressionMatchString(0)
Wend
EndIf
Else
Debug RegularExpressionError()
EndIf
I only get xab, not xabc. If I use a double ape I only get xxa, which tells me there is something wrong with character/byte count.
(Linux 64)