[Gambas-user] Regexp Error at compile time: 'Bad Character Constant String'

Alain Baudrez a.baudrez at ...626...
Sat Oct 26 15:28:38 CEST 2013


OK.

The doc must be adapted then, because I took it directly from
http://gambasdoc.org/help/comp/gb.pcre/regexp?v3

A.J.


2013/10/26 Benoît Minisini <gambas at ...1...>

> Le 26/10/2013 13:10, Alain Baudrez a écrit :
> > 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?
> >
>
> The "\" character must be quoted in Gambas strings, i.e. you must write
> two "\" so that the gb.pcre component receives one.
>
> --
> Benoît Minisini
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list