Author |
Message
|
kevinmark99 |
Posted: Mon May 06, 2013 1:09 pm Post subject: Regualr Expression search in ESQL |
|
|
Newbie
Joined: 29 Mar 2013 Posts: 8
|
ESQL NEWBIE QUESTION:
I have a email ID
datacenter009@gmail.com
ESQL needs to identify this email ID with pattern
datacenter[number][number][number]@gmail.com & transform to
datacenter[number][number][number]dev@gmail.com
How can this be achieved in ESQL? Does ESQL support regular expression? |
|
Back to top |
|
 |
mqjeff |
Posted: Mon May 06, 2013 4:29 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
does it really need to be that specific?
Or can it merely substring BEFORE '@' ? |
|
Back to top |
|
 |
mqsiuser |
Posted: Mon May 06, 2013 11:39 pm Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
ESQL is designed for speed and simplicity.
And fit for a particular purpose: msg processing & transformation.
It somewhat spares (by intention) big librarys (provided by FUNCTIONs/PROCEDUREs), while other languages, like C++(STL), JAVA(JCL), PERL(CPAN) or Python(Python Standard Library) are extremely proud of theirs.
But you can use other nodes or WRAPPER-Functions (to call e.g. into Java).
In ESQL it is "based on a few primitive Functions, write your own (waste or save the performance yourself )".
Though I would consider mqjeffs suggestion or if you "require" a reg exp, consider to do it the Broker-way: With a message set.
Or (as mqjeff says) the other broker way: Not with reg exps (Validating/EVALuating can(likely) hurt(s) performance).
Though it depends on the reg exps that you come up with (use simple ones) and the engine you use (probably Broker's parsers, e.g. MRM, are the fastest solution). _________________ Just use REFERENCEs |
|
Back to top |
|
 |
adubya |
Posted: Tue May 07, 2013 5:09 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
ESQL does not have sophisticated regex capability. You could implement regex checking in a Java class and call that from ESQL. |
|
Back to top |
|
 |
Vitor |
Posted: Tue May 07, 2013 5:09 am Post subject: Re: Regualr Expression search in ESQL |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kevinmark99 wrote: |
How can this be achieved in ESQL? Does ESQL support regular expresson? |
ESQL does not support regular expressions.
If the data is part of an input message then consider having a message set do the validation.
If that's not possible for any reason your best recourse is to produce a small Java function that takes a string & reg ex expression as parameters & returns a result. Be sure it's small, tight, efficient and doesn't leak memory. You can call this directly from your ESQL. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kash3338 |
Posted: Wed May 08, 2013 4:52 am Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
If the pattern you have specified is very specific, then you can better do this with a simple Java function and invoke from your ESQL code. If it's just going to be a check on EMail address (@) you can do that using simple ESQL functions.
ESQL does not support RegEx pattern, but to some extent can be acheived through manual code checks. Depending on the complexity you can chose between ESQL and Java. |
|
Back to top |
|
 |
anurag.munjal |
Posted: Wed May 08, 2013 9:15 am Post subject: ESQL |
|
|
 Voyager
Joined: 08 Apr 2012 Posts: 97
|
Try this out!
Code: |
SET A = SUBSTRING('datacenter009@gmail.com' BEFORE '@');
--Sets A = 'datacenter009';
SET B = SUBSTRING('datacenter009@gmail.com' AFTER '@');
--Sets B = 'gmail.com';
SET Final_Email_ID = A ||'dev@' || B
--Sets Final_Email_ID = 'datacenter009dev@gmail.com';
|
 |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 08, 2013 10:03 am Post subject: Re: ESQL |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
anurag.munjal wrote: |
Try this out!
Code: |
SET A = SUBSTRING('datacenter009@gmail.com' BEFORE '@');
--Sets A = 'datacenter009';
SET B = SUBSTRING('datacenter009@gmail.com' AFTER '@');
--Sets B = 'gmail.com';
SET Final_Email_ID = A ||'dev@' || B
--Sets Final_Email_ID = 'datacenter009dev@gmail.com';
|
 |
That doesn't validate an email address in the way
Code: |
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b |
does.
Nor does it directly answer the OP's stated intent to extract part of the non-domain portion. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu May 09, 2013 9:20 am Post subject: Re: ESQL |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Vitor wrote: |
anurag.munjal wrote: |
Try this out!
Code: |
SET A = SUBSTRING('datacenter009@gmail.com' BEFORE '@');
--Sets A = 'datacenter009';
SET B = SUBSTRING('datacenter009@gmail.com' AFTER '@');
--Sets B = 'gmail.com';
SET Final_Email_ID = A ||'dev@' || B
--Sets Final_Email_ID = 'datacenter009dev@gmail.com';
|
 |
That doesn't validate an email address in the way |
for most values of validate, that's a correct statement.
Vitor wrote: |
Code: |
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b |
does. |
for at least some values of 'validate' that is not a correct statement.
Vitor wrote: |
Nor does it directly answer the OP's stated intent to extract part of the non-domain portion. |
In fact, it directly does the transformation that the OP wanted to achieve, which is to insert the word "dev" before the @ sign in an email address.
The OP didn't state a specific need to actually confirm that the part before the @ sign was of the pattern 'datacenterNNN'.
That's why I asked if it was strictly necessary to do so.
If it's not strictly necessary to do so, then the solution presented by anurag.munjal is strictly correct for the OP's stated needs. |
|
Back to top |
|
 |
|