Help with Replace Text Regex

Hi!  Struggling to figure out how to replace this: { "value":"Email", "id":"13469" }  with this: Email

 

Any ideas?

Comments

  • GrantSmith
    GrantSmith Indiana 🟤

    You can utilize a two step regex in a Replace Text block. See the attached images on how it's done. This is under the assumption it's in the same order / format each time.

     

    It would be easier if Domo supported RegEx Match Groups so you could easily just utilize the number shortcuts for the groups it matches within parentesis.

     

    The other option would possibly utilize the regex functions in your database if that's an option.

     

    Screen Shot 2020-01-30 at 8.41.51 AM.png

    Make sure you select RegEx from both gear wheels under the search term

  • Unfortunately,Screen Shot 2020-02-04 at 4.12.32 PM.pngScreen Shot 2020-02-04 at 4.11.58 PM.png this did not work.  I made sure that regex was selected for both options... here's a screen shot of what I included in the ETL step and the output....  any other ideas?

  • I would suggest using this RegEx under the term to search for:

     

    ^{"value"\s*:\s*"(.*)",.*}$

     

    And put $1 in the Replace field.

     

    You'd only need one entry that way. It will capture everything after the colon and quote and before the following quote. Can you give that a try and see how that goes?

  • GrantSmith
    GrantSmith Indiana 🟤

    You might also need to have a space inbetween the first { and the "

     

    ^{ *"value"\s*:\s*"(.*)",.*}$

    This version would handle if there is a leading space or not.

  • It doesn't like the regex.  Have a look at the screenshot.  Screen Shot 2020-02-04 at 5.11.45 PM.png

  • I tried it with the space as well.  No dice.

  • Sorry, my fault... I forgot to escape the curly braces. The RegEx engine that MagicETL uses will require that.

     

    ^\{\s*"value"\s*:\s*"(.*)",.*\}$

  • Still not working.  Unfortunately.

  • Very odd... It worked in my testing with the example you provided. Can you post some screen shots of what you're seeing now, or give some more detail around how it isn't working?

  • sure.  Here goes....  First Image is output.  Second image is what we did.

     

    Screen Shot 2020-02-05 at 1.14.43 PM.pngScreen Shot 2020-02-05 at 1.13.27 PM.png

  • I wonder if we're seeing some whitespace after or before the value. What if you added in a check for that like this:

     

    ^.*\{\s*"value"\s*:\s*"(.*)",.*\}.*$

     

     

  • deleted (dupe)

  • Still no dice.  I copied your code in, reran and took a screenshot of the output.  Still not replaced.  See:

     

    Screen Shot 2020-02-05 at 3.56.02 PM.png

  • For anyone else running into this issue, you need to select the "Use RegEx" option from the field settings where you add your actual RegEx. It won't work until you do this.


  • jaeW_at_Onyx
    jaeW_at_Onyx Budapest / Portland, OR 🟤

    Just in case you want to parse multiple objects gracefully. You can do this in MySQL. but actually Magic 2.0 with a little creativity supports a similar workflow with the Add Formulas tile.



Sign In or Register to comment.

Hey, Stranger!

It looks like you're new here. Those who sign in get access to engage with even MORE fire content. To get involved, click one of these buttons!