cancel
Showing results for 
Search instead for 
Did you mean: 

Wildcard string replacement ?

dunncrew
Deputy Chef III
Deputy Chef III

Hi, is there a way to replace characters using a wildcard  with a blank ?

There are always 6 zeroes, and random 3 digits and a period before the 6 zeroes

2023-10-09 17:38:36.243000000   More text here                                                                    

2023-10-09 17:42:37.770000000   More text here 

Becomes

2023-10-09 17:38:36  More text here                                                                    

2023-10-09 17:42:37   More text here 

 

1 ACCEPTED SOLUTION

gary1
Executive Chef II
Executive Chef II

Hi, me again. You can use gsub with a regular expression (regex).

The below regex looks for a period followed by any quantity of numbers and removes them.

[message].gsub(/[.][0-9]+/,"")

Example: "2023-10-09 17:38:36.243000000" becomes "2023-09 17:38:36"

There are a million regex sites out there but I find this one particularly helpful: https://regexr.com/

View solution in original post

2 REPLIES 2

gary1
Executive Chef II
Executive Chef II

Hi, me again. You can use gsub with a regular expression (regex).

The below regex looks for a period followed by any quantity of numbers and removes them.

[message].gsub(/[.][0-9]+/,"")

Example: "2023-10-09 17:38:36.243000000" becomes "2023-09 17:38:36"

There are a million regex sites out there but I find this one particularly helpful: https://regexr.com/

dunncrew
Deputy Chef III
Deputy Chef III

Thanks. I will add that to my "Tips & Tricks" document I am making for myself.