Forum Discussion
Here is a version 2 of the pipeline that uses a Mapper and Splitter (instead of Pivot snap) for a dynamic pivot of the data. Community.10510_2021_08_05 (v2).slp (32.8 KB)
I’m not sure about performance, either, but I don’t know how you use your validator snap as-is without splitting/pivoting the data - because of the duplicate key issues.
As this is to be a generic pipeline, I think you might be better off using an Expression Library
in place of (or in conjunction with) your Validator. I think you could avoid the pivot, then.
@del Thank you so much… this is what I was exactly looking for. I will verify the performance and update you…
Can you provide example if possible about the way it can be done with expression library. As data validator does not allow any expression library or parameters used I am not sure how this can be achieved in a mapper using expression library.
I don’t think you need to use .match() - but a slight update to @siwadon’s solution might resolve multiples within the notes:
$notes.replace(/.*(#IF:.{9}).*/g, (...args) => args[1].slice(-9))
The “g” at the end of the pattern tells it to search the string globally. The slice(-9) will give only the 9 characters following the #IF. Multiple matches are separated with a \n (newline) character.
- JensDeveloper4 years agoContributor II
Hi,
I tested both but it still shows text after the nine characters. on the second one. Is it because thats a new line of text?
$notes.replace(/.*(#IF:.{9}).*/, (...args) => args[1])
It replaces the matched string with the first capture group (#IF: and the following 9 characters).
This will not work correctly when the input contains multiple matches. If that’s the case, please let me know. You might need to use
.match()
instead.It’s the newline character in the string that is causing the issue. The dot notation for character matching in regex does not match newlines. After a bit of thought, we can also simplify the result by using the regex group capture syntax. Try this:
$notes.replaceAll('\n','').replace(/.*#IF:(.{9}).*/g, '$1')
- JensDeveloper4 years agoContributor II
Thank you it works now. I get it now. Still improving my regex 🙂
- darshthakkar4 years agoValued Contributor
Thank you @JensDeveloper for raising this, I got to learn something new as well.
@koryknick and @siwadon’s suggestion and help on this one has been much appreciated.
Related Content
- 10 months ago
- 11 months ago