Regular Expressions - Extraction and Group Logic support

More
10 years 10 months ago #13520 by daniel.fung@xerox.com
Can you tell me if you can support more advanced regular expressions besides the matches true/false support that you currently have.

for sample imagine that I have a string such as below,

ABC1CTL_0_20150821_0.TXT where all I know of before hand is - there is a CTL and a YYYYMMDD date in the string

hence the name confirms to .*CTL.*[0-9]{8}.*\.TXT

I need however get the bit before the CTL and the YYYYMMDD part

in the regular expression handling world, I would specify an expression such as

(?<startfield>.*)CTL.*_(?<datefield>[0-9]{8}).*\.TXT

where startfield and datefield are two GROUPS.

I would then say if str ( i cannot completely show this in pascal, but the idea is that i can target groups - named preferred, numbered are ok too.

s := 'ABC1CTL_0_20150821_0.TXT ';
r := '(?<startfield>.*)CTL.*_(?<datefield>[0-9]{8}).*\.TXT';

m := RegularExpressionMatches(s,r,0); // where the 0 is the input for options such as ignore case etc,

matches = length(m);

//loop thru 1 to matches to get the groups

m(0) // startfield
m(1) // datefield

Or using the group names where i can then say

res : string;

res := matches.Result($startfield);

or even

res := matches.Results('startfield');

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago #13547 by admin
Thank you for the feedback
Our developers will investigate it for you

Mike
ETL Architect

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago #13580 by admin
Daniel

The regular expressions engine we had until now did not support groups.
It was quite old so we had to update it to make it work.
In the latest version we added two new functions
Replace RegX and Split RegX

Split RegX can be used to split string based on regular expression

For example




I hope this will help you to achieve your objective

Mike
ETL Architect
Attachments:

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago - 5 years 1 month ago #21098 by admin
Hi Daniel

Just letting you know that we added "Use groups" option to Split RegX transformation function
By default, it is set to true and should have no effect on existing transformations


Mike
ETL Architect
Attachments:
Last edit: 5 years 1 month ago by admin.

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save