Transactions:
Load
recno() as RecordID,
ExtractRegExGroup(TransactionCode,'([0-9]{4})-(ONLINE|INSTORE)-([0-9]{5})',0) as TransactionCode_Unparsed,
ExtractRegExGroup(TransactionCode,'([0-9]{4})-(ONLINE|INSTORE)-([0-9]{5})',1) as TransactionYear,
ExtractRegExGroup(TransactionCode,'([0-9]{4})-(ONLINE|INSTORE)-([0-9]{5})',2) as TransactionSource,
ExtractRegExGroup(TransactionCode,'([0-9]{4})-(ONLINE|INSTORE)-([0-9]{5})',3) as TransactionDC,
* Inline `
TransactionCode, Category
2025-ONLINE-60019, Product A
2024-INSTORE-60020, Product B
2025-ONLINE-60018, Product C
2024-ONLINE-60020, Product A
2025-INSTORE-60019, Product B
2025-ONLINE-60017, Product D
`;
結果
載入資料並開啟工作表。建立新的表格並將這些欄位新增為維度:
RecordID
TransactionCode
TransactionCode_Unparsed
TransactionYear
TransactionSource
TransactionDC
結果表格
RecordID
TransactionCode
TransactionCode_Unparsed
TransactionYear
TransactionSource
TransactionDC
1
2025-ONLINE-60019
2025-ONLINE-60019
2025
ONLINE
60019
2
2024-INSTORE-60020
2024-INSTORE-60020
2024
INSTORE
60020
3
2025-ONLINE-60018
2025-ONLINE-60018
2025
ONLINE
60018
4
2024-ONLINE-60020
2024-ONLINE-60020
2024
ONLINE
60020
5
2025-INSTORE-60019
2025-INSTORE-60019
2025
INSTORE
60019
6
2025-ONLINE-60017
2025-ONLINE-60017
2025
ONLINE
60017
這些結果醒目提示了如何透過 group 引數為多個操作重複使用單一 Regex。TransactionCode_Unparsed 欄位使用 group 值 0,在這種情況下不提供任何附加價值,在此處顯示僅出於示範函數之目的。
BusinessContactInfo:
Load
ExtractRegExGroupI(ContactInfo, '([a-zA-Z0-9!#$%^&*-_+=~{|}\/.'']+@[a-zA-Z0-9!#$%^&*-_+=~{|}\/.'']{1,50}\.[a-zA-Z0-9!#$%^&*\-_+=~{|}\/.'']{1,50})|(\({0,1}[0-9]{3}\){0,1}[ -]*[0-9]{3}[ -]*[0-9]{4})',1,1) as CompanyEmail,
ExtractRegExGroupI(ContactInfo, '([a-zA-Z0-9!#$%^&*-_+=~{|}\/.'']+@[a-zA-Z0-9!#$%^&*-_+=~{|}\/.'']{1,50}\.[a-zA-Z0-9!#$%^&*\-_+=~{|}\/.'']{1,50})|(\({0,1}[0-9]{3}\){0,1}[ -]*[0-9]{3}[ -]*[0-9]{4})',2,2) as CompanyPhoneNum,
* Inline `
ID CompanyName ContactInfo
1 Company A Email is: Company1@example.com, Phone number is: (123) 456-7890
2 Company B Email is: company2@test.com, Phone # is: 0123456790
3 Company C Email is: company3@placeholder.com, Phone no. is: 234-567-8901
` (delimiter is '\t');
SET ISBN_RegEx = 'ISBN[ ]*([0-9]{3})-([0-9]{1})-([0-9]{4})-([0-9]{4})-([0-9]{1})';
ISBN:
LOAD Supplier,
ExtractRegExGroup(Books,'$(ISBN_RegEx)',1) AS EAN,
ExtractRegExGroup(Books,'$(ISBN_RegEx)',2) AS Group,
ExtractRegExGroup(Books,'$(ISBN_RegEx)',3) AS Registrant,
ExtractRegExGroup(Books,'$(ISBN_RegEx)',4) AS Publication,
ExtractRegExGroup(Books,'$(ISBN_RegEx)',5) AS Checksum;
// Split the ISBN with the Group function in a preceding load to avoid generating a cartesian product
LOAD *,
ExtractRegEx(SupplierBooks, '$(ISBN_RegEx)') AS Books
INLINE [
Supplier, SupplierBooks
Supplier 1, ISBN 123-3-1234-1234-0 ISBN 012-2-0123-0123-4 ISBN 000-1-0123-0123-2 ISBN 234-5-2345-2345-1 ISBN 555-2-5555-5555-3 ISBN 222-4-2222-2222-2
Supplier 2, ISBN 000-0-3333-3333-3 ISBN 333-3-3333-3333-3 ISBN 555-1-5151-5151-3 ISBN 232-1-2323-2323-1 ISBN 008-0-7777-7777-3 ISBN 888-0-9999-0000-0
];
BusinessContactInfo:
Load * Inline `
ID CompanyName ContactInfo
1 Company A Email is: Company1@example.com, Phone number is: (123) 456-7890
2 Company B Email is: company2@test.com, Phone # is: 0123456790
3 Company C Email is: company3@placeholder.com, Phone no. is: 234-567-8901
` (delimiter is '\t');
Correspondence:
Load * Inline `
ID EmailBody
1 Thanks again for this morning's meeting! You can find the meeting minutes posted here: https://example.com/resourceexample. If you still have any questions, always feel free to ask me or one of the other team members. Here are a few learning resources that might help you: http://www.example.ca/training1.pptx http://www.example.ca/training2.pptx http://www.example.ca/training3.pptx Thanks again!
2 Hi, you'll want to visit our company website for that, it's available at https://www.example.se.
3 Hello all, I just wanted to let you know that our online stores are now up and running! I couldn't be more excited. We are already seeing quite a bit of traffic and volume sold, which is very promising! For Product A, go to https://www.examplestore1.com/products. For Product B, you'll want go to https://www.examplestore2.com/products. Product C, go check out https://www.examplestore3.com/products. Cheers!
` (delimiter is '\t');