Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

RegEx - specific expression searched

Newbee3
6 - Meteoroid

Hey everyone

 

I would - once more - highly appreciate your help on following request. I need to extract certain data from a string. Please find below some sample data extracts:

 

 Raw datatarget extract 
Deposits-QQ
Deposits-1Q201Q20
Short-term borrowings-6M196M19
Trading liabilities-6M196M19
Central bank funds purchased, securities sold under repurchase agreements and securities lending transactions-2Q192Q19
Other-Q-1qQ-1q
of which loans held-for-sale reported at lower of cost and market value (amortized cost base)-Q-1qQ-1q
Obligation to return securities received as collateral, at fair value-Q-2qQ-2q
Additional paid-in capital-QQ

 

I would highly appreciate if you could provide me with the respective RegEx function. Currently I am going with "REGEX_Replace([annual/quarterly report], "(.)*-Q", 'Q')" which is not working properly as you can guess. Due to the complex structure of the workflow I would appreciate - if possible - that the solution focuses on the RegEx_replace function rather than a work around.

 

Thank you very much upfront.

4 REPLIES 4
jdunkerley79
ACE Emeritus
ACE Emeritus

Based on your sample, a regular expression of:

 

.*?-(\d*[QM](\d*|[-]\d+q))$

 

should get the value you want into $1.

  • First it no greedily matches the start of the string
  • Looks for a - followed by either numbers then a Q/M or just a Q/M (\d*[QM])
  • Then it allows a choice either possibly numbers (\d*) or a block starting with a minus then some numbers and then a q ([-]\d+q)
  • The last $ makes it match until the end of the string

 

 

So a formula of:

 

REGEX_Replace([ Raw data], ".*?-(\d*[QM](\d*|[-]\d+q))$", "$1")

 

should work

 

Have attached a sample. 

atcodedog05
22 - Nova
22 - Nova

Hi @Newbee3 ,

 

Here is workflow for the task.

 

Output:

atcodedog05_0-1601883955944.png

Workflow:

atcodedog05_1-1601883975814.png

Hope this helps 🙂

 

If this post helps you please mark it as solution. And give a like if you dont mind 😀👍

Newbee3
6 - Meteoroid

okay, I guess I am a bit blown away 'caus:

1. the response was super fast

2. the regex is really complex

 

Would not have been able to solve this myself! Thank you!

atcodedog05
22 - Nova
22 - Nova

I agree on that part @jdunkerley79  is amazing with Regex 😎

Labels
Top Solution Authors