StartsWith(string, prefix)

Hi all

I need to find out if a company name starts with ‘The’ and if so remove it.

i.e. If a company name is ‘The Breakfast Club’ then the result will be ‘Breakfast Club’

I believe the ‘StartsWith’ formula should do this but I can’t work out how.

Here’s my attempt: IF([Company Name]=StartsWith(“The”), )

I don’t think i’m even close.

Thanks

Hi,

You can accomplish this using the RegexReplace formula. This takes a value (your company name), a regular expression and a replacement string. Try [Company Name].RegexReplace("^The ", ""). This will match any value starting with "The " (case sensitive) and replace it with a blank value. If you want to match the or The as a prefix you’ll need to use [Company Name].RegexReplace("^[Tt]he ", "")

Another way to accomplish this is by matching using startsWith and then dropping the first four characters: If([Company Name].Upper().StartsWith("THE "), [Company Name].Slice(4), [Company Name])

image

Hope this helps,
Nigel.

1 Like

Thanks, that worked a treat.