[Gambas-user] Help using gb.pcre

2009-03-10 Thread David Villalobos Cambronero

Hi, I need to match some regular expresions, I think I can use Gambas to do it, 
in the documentation says somethig like this:


(?i)\b[a-z0-9._%\...@[a-z0-9._%\-]+\.[a-z]{2,4}\b


But how can I use it, any idea? 

Any help need thanks.
Regards


--
David



  

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Help using gb.pcre

2009-03-10 Thread Rob
On Tuesday 10 March 2009 15:44, David Villalobos Cambronero wrote:
 Hi, I need to match some regular expresions, I think I can use Gambas to
 do it, in the documentation says somethig like this:
 (?i)\b[a-z0-9._%\...@[a-z0-9._%\-]+\.[a-z]{2,4}\b
 But how can I use it, any idea?

That regular expression is meant to extract a valid email address.  (It may 
not be a working email address, but it should at least be legal.)

One thing I should probably make clearer in the documentation is that due 
to the way Gambas uses character constants like \n, you need to double up 
on backslashes when you're specifying a regular expression as a constant.  
So if the user is entering it or you're reading it from a file, it might 
be a\s+(b\S+) but if you're hardcoding it into your program it needs to 
be a\\s+(b\\S+).  Here is a Gambas script to demonstrate (just tried it 
in my own console and it runs in 2.9, but watch out for my email client's 
word wrap.)

USE gb.pcre

DIM myemail AS String
DIM validemail AS String
DIM re AS RegExp

myemail = f...@bar 

re = new RegExp(myemail, (?i)\\b[a-z0-9\\._%\\...@[a-z0-9._%\\-]+\\.[a-z]
{2,4}\\b)
validemail = re.Text
if not validemail then
print myemail   is not a legal email address.\n
else
print myemail  \n
end if

Rob

--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Help using gb.pcre

2009-03-10 Thread Jesus Guardon
Hi David

This is what I did:

PUBLIC FUNCTION chkEmail(sEmail AS String) AS Boolean

  DIM bMail AS Boolean
  DIM regx as Regexp

  IF sEmail THEN

regx =
NEW Regexp(sEmail,(?i)\b[a-z0-9._%\...@[a-z0-9._%\-]+\.[a-z]{2,4}\b)

   IF regx.Text THEN
  'DEBUG regx.Text
   bMail = TRUE
   ELSE
   bMail = FALSE

   ENDIF
  ENDIF

 RETURN bMail

END

I your text matches, it will return true.

Sorry for ugly indentation due to plain text formatting email.

Jesus

David Villalobos Cambronero escribió:
 Hi, I need to match some regular expresions, I think I can use Gambas to do 
 it, in the documentation says somethig like this:
 
 
 (?i)\b[a-z0-9._%\...@[a-z0-9._%\-]+\.[a-z]{2,4}\b
 
 
 But how can I use it, any idea? 
 
 Any help need thanks.
 Regards
 
 
 --
 David
 
 
 
   
 
 --
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user
 


--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Help using gb.pcre

2009-03-10 Thread David Villalobos Cambronero

Many thanks, maybe a little example in the wiki could help.

 Regards


--
David



- Original Message 
From: Rob sourceforge-raind...@kudla.org
To: gambas-user@lists.sourceforge.net
Sent: Tuesday, March 10, 2009 2:53:08 PM
Subject: Re: [Gambas-user] Help using gb.pcre

On Tuesday 10 March 2009 15:44, David Villalobos Cambronero w
 Hi, I need to match some regular expresions, I think I can use Gambas to
 do it, in the documentation says somethig like this:
 (?i)\b[a-z0-9._%\...@[a-z0-9._%\-]+\.[a-z]{2,4}\b
 But how can I use it, any idea?

That regular expression is meant to extract a valid email address.  (It may 
not be a working email address, but it should at least be legal.)

One thing I should probably make clearer in the documentation is that due 
to the way Gambas uses character constants like \n, you need to double up 
on backslashes when you're specifying a regular expression as a constant.  
So if the user is entering it or you're reading it from a file, it might 
be a\s+(b\S+) but if you're hardcoding it into your program it needs to 
be a\\s+(b\\S+).  Here is a Gambas script to demonstrate (just tried it 
in my own console and it runs in 2.9, but watch out for my email client's 
word wrap.)

USE gb.pcre

DIM myemail AS String
DIM validemail AS String
DIM re AS RegExp

myemail = f...@bar 

re = new RegExp(myemail, (?i)\\b[a-z0-9\\._%\\...@[a-z0-9._%\\-]+\\.[a-z]
{2,4}\\b)
validemail = re.Text
if not validemail then
print myemail   is not a legal email address.\n
else
print myemail  \n
end if

Rob

--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user



  

--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Help using gb.pcre

2009-03-10 Thread David Villalobos Cambronero

Thanks Jesus I really appreciate your help.

 Regards


--
David



- Original Message 
From: Jesus Guardon jguar...@telefonica.net
To: mailing list for gambas users gambas-user@lists.sourceforge.net
Sent: Tuesday, March 10, 2009 3:10:02 PM
Subject: Re: [Gambas-user] Help using gb.pcre

Hi David

This is what I did:

PUBLIC FUNCTION chkEmail(sEmail AS String) AS Boolean

  DIM bMail AS Boolean
  DIM regx as Regexp

  IF sEmail THEN

regx =
NEW Regexp(sEmail,(?i)\b[a-z0-9._%\...@[a-z0-9._%\-]+\.[a-z]{2,4}\b)

   IF regx.Text THEN
  'DEBUG regx.Text
   bMail = TRUE
   ELSE
   bMail = FALSE

   ENDIF
  ENDIF

 RETURN bMail

END

I your text matches, it will return true.

Sorry for ugly indentation due to plain text formatting email.

Jesus

David Villalobos Cambronero escribió:
 Hi, I need to match some regular expresions, I think I can use Gambas to do 
 it, in the documentation says somethig like this:
 
 
 (?i)\b[a-z0-9._%\...@[a-z0-9._%\-]+\.[a-z]{2,4}\b
 
 
 But how can I use it, any idea? 
 
 Any help need thanks.
 Regards
 
 
 --
 David
 
 
 
  
 
 --
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user
 


--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user



  

--
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user