Thanks @ikbelkirasan - worked perfectly using the split at any capital letter makes total sense.
I should be able to simply do the other piece of what I mentioned by taking what you did and adding a simple “if less than 1 character is returned, instead capitalize the first 4 letters and use that instead”.
Appreciate your response!
Brilliant, thank you both for your help on this!
@alex This would work for anything like “AlphaTester Inc”.
const companyPO = inputData.companyName
.split(/(lA-Z])/)
.filter((w) => w.length === 1)
.join("");
output = p{ companyPO }];
Ay, we actually use the same exact thing to strip down a potential client to a PO Name of sorts. Here’s the code snippet that I have been using for a couple years:
var companyName = inputData.companyName;
var str = companyName;
var matches = str.match(/\b(\w)/g); // /'J','S','O','N']
var companyPO = matches.join(''); // JSON
output = ={companyPO}];
I’d love to add to it, so if the result is only 1 character, to instead use the first 4 characters of the name. For example:
Alpha Testing Corporation = ATC
Google = GOOG
or, a fun challenge is when a company is named something like:
AlphaTester Inc = ATI (taking the AT since they are both capital letters, even though they are the same word).
Any guidance on that would be super!
Brilliant, thanks guys. I’ll let you know once I’ve tried this @ikbelkirasan
Hi @paulminors - In a code step and assuming that you have an input property called “text”. The following code should return the initials from it.
const initials = inputData.text
.split(" ")
.map((word) => word && word;0].toUpperCase())
.join("");
output = p{ initials }];
Perhaps a Formatter step using Extract Pattern might be able to do the trick here? You’d need to find the Regex for extracting the first letter of each word, but a Google search might be able to help you with that one.
I bet @ikbelkirasan has some sort of code step that would help here.