Original Message:
Sent: 06-14-2023 16:02
From: Alan Stevens
Subject: What does this Regex formula do
"\W+" will match one or more consecutive non-word characters. It can be used to identify and split text based on non-alphanumeric characters, such as spaces, punctuation marks, and special symbols.
So, for example, suppose you have a string for IT Tower-SubTower like "Compute-Servers". If you wanted to split the string, you'll need a regular expression that will identify the special character or delimiter. "\W+" (without the quotes) will select the "-". If you made it "Compute - Servers", it will select the spaces as well, so " - ". If you have users that sometimes use a dash, sometimes an underscore, and sometimes a pipe symbol (|), all with or without spaces with no rhyme or reason, it will select all of those as well without having to make changes to the formula.
Go to the regex 101 website and you can test all these cases out.
For the expression itself, the "\" is an escape that means the next character has special meaning - otherwise the expression would just look for a "W". As mentioned, "\W" means "find a non-word character." Adding the plus sign "\W+" means "match one or more characters," which is why it will expand the results from "-" to " - " with no changes.
I used to struggle to build these. Now I just ask ChatGPT to write them and life is good. Especially for regex for Apptio, which sometimes doesn't process the way I expect. In that case, I give ChatGPT the failed results I get back, and it makes recommendations on how to fix to get the right match and return the right group. Hope this helps!
Original Message:
Sent: 06-14-2023 12:54
From: Kristine Klein
Subject: What does this Regex formula do
Thank you so much that makes a lot of sense. I tried to google that but it doesn't work very well when you google [^a-zA-Z0-9_])
------------------------------
KristineKleinTerex CorporationSenior Operations Specialist TBMA
Original Message:
Sent: 06-13-2023 18:07
From: Daniel Kelly
Subject: What does this Regex formula do
Sorry, I should have been clearer. I edited my original post, but I will also elaborate here.
So word characters, which are matched by "\w" (lower case "w") are in the set [^a-zA-Z0-9_]. Where the set is bounded by "[^" and "]". Or in plain English: lower case or upper case letters, the digits zero through nine, and the underscore character. The reason an underscore is part of the set of word characters is for cryptic historical reasons.
"\W" (capital "W") is non-word characters. So everything else like hyphens, "special characters" (e.g. !@#$% etc.).
Original Message:
Sent: 06-13-2023 17:54
From: Kristine Klein
Subject: What does this Regex formula do
Thanks. I understand now. what does this mean [^a-zA-Z0-9_])
------------------------------
KristineKleinTerex CorporationSenior Operations Specialist TBMA
Original Message:
Sent: 06-13-2023 17:50
From: Daniel Kelly
Subject: What does this Regex formula do
"\W" matches any non-word character (equivalent to [^a-zA-Z0-9_]). The "+" means one or more of the item.
So that statement is removing all non-word characters in the Journal Line Description.
Original Message:
Sent: 06-13-2023 17:38
From: Kristine Klein
Subject: What does this Regex formula do
Can anyone tell me what this formula is doing?
=ReplaceRegex(Journal Line Description,"\W+"," ")
------------------------------
KristineKleinTerex CorporationSenior Operations Specialist TBMA
------------------------------
#TBMStudio