โ10-11-2023 06:32 AM
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
Solved! Go to Solution.
โ10-11-2023 08:46 AM
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/
โ10-11-2023 08:46 AM
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/
โ10-11-2023 09:59 AM
Thanks. I will add that to my "Tips & Tricks" document I am making for myself.
โ08-31-2024 10:16 AM
Hi,
following up on this conversation. What if i want to replace spaces, commas, periods, etc from the string to an empty string. What should I provide in the find regex value?
Ex: string = abc, def inc.
output should be abcdefinc
<string>.gsub(?,'')
Thank you for your help!
Hilda.