How to turn "r1/r2/r3" into "p0/p0/p0" using RegexReplace function?

Today is my first day learning about the Regular expressions and I have accepted defeat.

The only thing I need it for is one specific thing, and I do not want to spend a weekend studying regular expressions.

Here is a doc that shows what I want to achieve.

Here you go @Fran_Vidicek :blush:

RegexReplace(thisRow.Column,"r\d{1,2}","p0" )

The Regular Expression "r\d{1,2}" will match the character r and any digit after that (but for a count in between 1 and 2 (\d{1,2}) and replace them by p0


Thank you very much!
It seems like there is someone active in the community at any hour of the day, that’s nice.

1 Like

What if there is "r" with more than 2 numbers after it (e.i. r463718/r3/4/r5)?
Is there a way to get the same result no matter the amount of numbers after the "r"

Is there something more elegant than ("r\d{1,9999}","p0" ) ?
Or would that even work the way I think it would.

No problem @Fran_Vidicek :wink: !

I’m honestly not a RegEx expert but this seems to work (I’ve added it to the sample above too :blush: )

RegexReplace(thisRow.Column,"r\d+","p0" )

The + means « one or more » so, \d+ is one or more digits :blush:

(And lol, yes, there’s always someone here :sweat_smile: … I should be sleeping by now but here I am :innocent: )

1 Like

Sweet! Thank you once again :pray:

Yeah, me too. It’s 3:00 AM here.

1 Like

You could do something a bit simpler in this case without regex!

You could likely just do
Repeat(“p0/“, column.split(“/“).count())

All that is doing is counting how many “r/“ things you have regardless of the number of digits after the r and then repeating your p0 string a matching number of times


Oh, thank you, that could come in handy too.
Could this function possibly be slightly faster than regex, when it comes to executing it ?

I know that feeling when you’re kind of stuck in your coda doc :sweat_smile:


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