Can i use .replace and .match together in expression editor?

Quick question.

I am trying to use the expression editor if I can to match a regex but append text to the end of it, whilst at the same time keeping the rest of the text the same way that .replace() does.

I want to use a mixture of .match() and .replace() to match my regex and then add a string on the end, whilst keeping the rest of the non matched text in the expression editor once the regex piece is finished.

Is this possible, or did I not explain that very well?

basically trying to do this

Hey @RedPacketSec,

Do you have a small example workflow that reproduces the issue?

i dont have any sample flow i can share

but basically if you have dummy date that says

123 456 789

and you want to match


and add +TEST

123 456+TEST 789

when you use .match() it removes the

123 789

when you use .replace(), it removes the


i want to be able to .match() and append but keep the other data around it

Hey @RedPacketSec,

I was able to build a quick example from that, What about just using replace() with the regex or does that start to get a bit crazy?

I guess match() will return the value so maybe what you need is a match in the replace :thinking:

yeah the regex matches an entire section of html, doing that replaces the html with just the last part, thats why i need it to match() then i can append, replace…replaces it and as its html i would need to use the match as the second part of the .replace()

The example kind of does that right? It is matching on a string then appending without issue. If you can update the example with content that is closer to what you are working with I might be able to do a bit more.

There is also the code as well if an expression is having a hard time.

@RedPacketSec perhaps a stupid question, but why not use the Code node witth .replace(x,y)?

i wanted to avoid the code node where possible but if that is my only option…

@RedPacketSec this may help you … How do I add this detail to the XML? - #4 by dickhoning

Hi @RedPacketSec would multiple replaces be an option? For example

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.