Skip to main content
Solved

SUBSTITUTE Formula - Not removing apostrophe

  • August 28, 2021
  • 2 replies
  • 39 views

Hey there, looking to create a simple slug and for some reason the apostrophe isn’t being removed.

Example Title: Zoom Fatigue is real, so let’s deal with it.

So make lowercase, remove apostrophes remove commas, remove full stops and replace spaces with dashes (etc) is what I’m after.

LOWER(
SUBSTITUTE(
	SUBSTITUTE(
		SUBSTITUTE(
			SUBSTITUTE(
				{Name}, "'",""
				),
				",", ""
			),
			".", ""
		),
		" ", "-"
	)
)

I cannot fathom why the apostrophe is not being removed. I’m missing something easy… ideas?

Best answer by Martin_Kopischk

Hard to tell because of the resolution of your screenshot, but might that apostrophe be a typographically correct one (), not the ASCII single quote (') your formula is replacing? You can cover that case and get rid of other nested SUBSTITUTEs by using REGEX_REPLACE. For instance, this:

LOWER(
  REGEX_REPLACE(
    REGEX_REPLACE(Name, "['’´,.]+", ""),
    "\s+", "-"
  )
)

will substitute a hyphen for whitespace and remove dots, commas and common apostrophe variants.

2 replies

Forum|alt.badge.img+4

Hard to tell because of the resolution of your screenshot, but might that apostrophe be a typographically correct one (), not the ASCII single quote (') your formula is replacing? You can cover that case and get rid of other nested SUBSTITUTEs by using REGEX_REPLACE. For instance, this:

LOWER(
  REGEX_REPLACE(
    REGEX_REPLACE(Name, "['’´,.]+", ""),
    "\s+", "-"
  )
)

will substitute a hyphen for whitespace and remove dots, commas and common apostrophe variants.


  • Author
  • Participating Frequently
  • August 30, 2021

Hard to tell because of the resolution of your screenshot, but might that apostrophe be a typographically correct one (), not the ASCII single quote (') your formula is replacing? You can cover that case and get rid of other nested SUBSTITUTEs by using REGEX_REPLACE. For instance, this:

LOWER(
  REGEX_REPLACE(
    REGEX_REPLACE(Name, "['’´,.]+", ""),
    "\s+", "-"
  )
)

will substitute a hyphen for whitespace and remove dots, commas and common apostrophe variants.


My dude! Thank you. I now know about REGEX-REPLACE. :pray: