[Gambas-user] Regexp Error at compile time: 'Bad Character Constant String'
Alain Baudrez
a.baudrez at ...626...
Sat Oct 26 13:10:37 CEST 2013
I would like to check the validity of an email using RegExp. gb.pcre has
been added to the project.
This is the code that I use to validate an email:
' Gambas class file
Private sRegExp As Regexp
Public Sub btnCheck_Click()
' RegEx pattern is taken from
http://gambasdoc.org/help/comp/gb.pcre/regexp
sRegExp = New Regexp(txtEmail.Text,
"(?i)\b[a-z0-9._%\-]+@[a-z0-9._%\-]+\.[A-Z]{2,4}\b")
If sRegExp.Offset = -1 Then Return
Message.Info("Result: " & sRegExp.Text)
End
I receive a 'Bad Character Constant String' on
"(?i)\b[a-z0-9._%\-]+@[a-z0-9._%\-]+\.[A-Z]{2,4}\b" at the first occurrence
of the [ and its matching ] at compile time.
Using "\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b" as regex pattern, I have
the Bad Character Constant String on the [ and ] surrounding the A-Z at the
end of the string.
It is my first go on using Regular Expressions. Is this a bug? or am I
doing something wrong here?
[System]
OperatingSystem=Linux
Kernel=3.5.0-42-generic
Architecture=x86_64
Distribution=Ubuntu 12.04.3 LTS
Desktop=GNOME
Theme=QGtk
Language=en_US.UTF-8
Memory=3687M
[Libraries]
Cairo=libcairo.so.2.11000.2
Curl=libcurl.so.4.2.0
DBus=libdbus-1.so.3.5.8
GStreamer=libgstreamer-0.10.so.0.30.0
GTK+=libgtk-x11-2.0.so.0.2400.10
OpenGL=libGL.so.1.2.0
Poppler=libpoppler.so.19.0.0
Qt4=libQtCore.so.4.8.1
SDL=libSDL-1.2.so.0.11.3
A.J.
More information about the User
mailing list