Remove a Date from a String

I have a Text String that sometimes contains a Date, if it exists I want to remove it.

Example: word1 word2 07/11/2022 word3, Convert to: word1 word2 word3

Sounds simple but I just cant figure it out.

Thanks for any help.

Hello John,

create a formula field and regex there
regexReplace({Test Regex},((0[1-9][\])|([12][0-9][\])|(3[01][\]))((0[0-9][\])|(1[012][\]))((20[012]\d|19\d\d)|(1\d|2[0123])) , )

{Test Regex} is your field containing date examples. works for dd/mm/yyyy format. You need to create regex for other formats

Sunny Singla

1 Like

Wow, thanks for getting back so quick Sunny, I have tried it and it it only extracts the year leaving the month and day!
However, using that as a template I have found this works: regexReplace({Test String},(\d{1,2})/(\d{1,2})/(\d{4}), )

Although that was more luck than judgement :slight_smile:



It’s works for me for dd/mm/yyyy format… your regex works for mm/dd/yyyy for mad dd/mm/yyyy as well as wrong date as well…

Like 20/20/2022

Ahhh I see why now I am writing apps for companies in the US as well as UK so my version should work for both.

Thanks for you help Sunny.

Hi again Sonny, I know we sorted the last challenge but working on the same text field I wanted to extract another string that was appearing: “-<”, I have tried it using extract: extract({test_field},-<, ) but when I save the field and reopen it I see: extract({test_field},- same with RegexReplace.

When I go to I have a string that works there but not in Knack, all I get after saving and opening is RegexReplace({test_field},-

I have tried escaping it with a backslash but to no avail.

Any Ideas?


Hello john,

For this, you need to create an extra formula field.


for some reason, knack does not support < character. so we need to create an extra field.

Sunny Singla

Hi Sunny

Thanks for that it works a treat although I did make a small modification to the above, I am always wary of too many calculation fields slow things down so I have made the formula field a text field and populated it on creation.

As always many thanks for your time and sharing your knowledge.