Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
xyz_1011
Partner - Creator II
Partner - Creator II

Extract substring from string (using RegEx ?)

Hi all,

in my automation i would like to extract a certain substring from a given string. The string is a path like this: 02_TRANSFORM/04_MARKETING/Leads.qvs and extract the last folder from the path. In this case the string i want to extract is 04_MARKETING 

I tried using a RegExParse() in an Output block: {regexparse: {$.loop3.item}, '.*\\([^\\]+)\\'}

Maybe RegEx is the right approach; maybe not...but i would appreciate any hint or advise.

Thanks!

Labels (2)
1 Solution

Accepted Solutions
Madhushree_BP
Former Employee
Former Employee

Hi @xyz_1011 ,

Can you use the below expression in your formula to extract the substring?

'/.*\/(.*)\/(.*)$/'

Please find the attached screenshot which helps. Let me know if this solution works for you.

Thanks

RegularExpression_test.JPG

 

View solution in original post

4 Replies
xyz_1011
Partner - Creator II
Partner - Creator II
Author

...so i found a regex that does what i need (tested in regex101): 

 .*\/([^\/]+)\/ 

but in my automation it fails:

xyz_1011_0-1681207927154.png

 

any idea, why ?

Madhushree_BP
Former Employee
Former Employee

Hi @xyz_1011 ,

Can you use the below expression in your formula to extract the substring?

'/.*\/(.*)\/(.*)$/'

Please find the attached screenshot which helps. Let me know if this solution works for you.

Thanks

RegularExpression_test.JPG

 

marcus_sommer
MVP
MVP

If the normal Qlik functions are available the above request should be solvable with normal string-functions like subfield() or textbetween().

xyz_1011
Partner - Creator II
Partner - Creator II
Author

@marcus_sommer  I would love this....as an old-school-qv-nerd, some of what i try to do in automations would then be doable in no time 🙂