How to remove internal spaces or hyphens with formatter

Hi! I am trying to compare a number pulled from a DataBlaze table with a number entered into a form (to confirm they match). However, the form entry number may have spaces or hyphens in it, which should be ignored for the purposes of the comparison. What's the best way to do this?

For example, the EAN pulled from the db table may be 66591 and the form entry may be 66-59-1 or 6659 1. For my purposes, these are a match.

Here's what I have so far. I've been trying to find a way to use formatter to strip spaces or hyphens (or extract only numerals) from "top isbn," but it's over my head. Thanks!

{dbselect: SELECT EAN FROM Sam's; space=4PBMN6kQLs5Gmzuvk8bha6; menu=yes}
{formtext: name=top isbn}
top isbn {if: ean == top isbn}good{else}error{endif}

PS from the answer to someone else's Q, I see how I can use {=replaceregex(top isbn, "[ -.&()]", "", "g")} to remove these characters, but I can't figure out where/how to use it in my snippet to run this comparison.

PS figured it out!

top isbn {if: ean == replaceregex(top isbn, "[ -]", "", "g")}good{else}error{endif}

Hi @megan.gendell, I'm glad you were able to resolve the issue.
One thing to more, you don't need two equal signs anymore. {if: ean = replaceregex(top isbn, "[ -]", "", "g")}good{else}error{endif}

1 Like