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 引数によって、1 つの正規表現を複数の操作に再利用できることを示しています。0 の group 値を使用する TransactionCode_Unparsed 項目はこの場合追加の値を提供しませんが、関数を示す目的でここに示されています。
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');
結果
データをロードしてシートを開きます。新しいテーブルを作成し、これらの項目を軸として追加します:
CompanyName
CompanyEmail
CompanyPhoneNum
結果テーブル
CompanyName
CompanyEmail
CompanyPhoneNum
Company A
Company1@example.com
(123) 456-7890
Company B
company2@test.com
0123456790
Company C
company3@placeholder.com
234-567-8901
同じ複合正規表現を再利用して、異なる情報を取得します。引数 group は、正規表現の 2 つのグループのうちどちらを検索するかを指定し、引数 field_no は、検索する全体的な一致 (文字列全体にわたって) を指定します。
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');