Forum Discussion

JensDeveloper's avatar
JensDeveloper
Contributor II
4 years ago
Solved

Map expression regex

Hi,

A simple one for the people that are expert in regex. I’m still learning it.
So, I have a key: notes that contains a value : #IF:SLG-01-SL + some text here”

My goal is to always get the 9 characters after an #IF:
My expression I tried in the regex and works: ([#IF:])(.{0,12})
But how do I put it into a mapper?
First i check whether the notes contains ‘#IF:’ if thats true it goes to the path where i need to do the regex in the mapper

$notes.replace($notes, /([#IF:])(.{0,12})/g)
but now it gives the string of the regex.

Regards

Jens

  • 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')
    

6 Replies

  • bojanvelevski's avatar
    bojanvelevski
    Valued Contributor

    You have a particular set of IDs you want to process, and that set counts 1000 records? Or you just want the first 1000 from the table?

    • darshthakkar's avatar
      darshthakkar
      Valued Contributor

      I’ve a specific set of 1000 IDs as of today, tomorrow it could be 5k, 0.5k or even 40k. Due to limited knowledge, I’m putting those IDs in the where clause of the query.

      • bojanvelevski's avatar
        bojanvelevski
        Valued Contributor

        Are you executing the pipeline, or just validating?