error 027: invalid character constant
#1

Hello,

I'm using regex replace to remove
Код:
nextid="checkpoint () (1231)"
from a line. I use expression nextid="\w+\s\(\)\s\([0-9]{1,5}\)"\s. This works on Notepad++ but when it comes to code below it give me error: error 027: invalid character constant

pawn Код:
regex_replace(line, 'nextid="\w+\s\(\)\s\([0-9]{1,5}\)"\s', "", line, sizeof line); // remove nextid from line.
I tried to escape "\" character with "\" but still get the same error.
Reply
#2

In PAWN single quote (') is used for single characters (try 'A' == 65), and double quote (") for strings. So:
pawn Код:
regex_replace(line, "nextid=\"\\w+\\s\\(\\)\\s\\([0-9]{1,5}\\)\"\\s", "", line, sizeof line);
(Take a note that I escaped double quotes inside the string)

#E:
Updated, you have to escape \ as well.
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
In PAWN single quote (') is used for single characters (try 'A' == 65), and double quote (") for strings. So:
pawn Код:
regex_replace(line, "nextid=\"\\w+\\s\\(\\)\\s\\([0-9]{1,5}\\)\"\\s", "", line, sizeof line);
(Take a note that I escaped double quotes inside the string)

#E:
Updated, you have to escape \ as well.
Thanks!! That solved the problem.

Edit: Pawn Compiled successfully but no replace done when file loaded.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)