Search code examples
jsonata

I need to remove the special characters like / using jsonata


Json

{ "Data":"i need , to do the transformation / but I am not able " }

I need to remove special characters using jsonata

The final output like be "IneedtodothetransformationbutIamnotable"

Please help me to find solutions


Solution

  • I believe this is what you're looking for:

    enter image description here

    Link to solution in JSONata playground: https://www.stedi.com/jsonata/playground?statev2=eJw1jc0KwjAQhF9lWDxUiNTfS8WbF5%2BhqbBtVy20SUlSEI3vbgp6GmaYb6YsydvJNUKK5Dk68b6zJhmO67hJ%2BoamMwfWVGjqYERaKASL1iI8BMGx8TfrBg4JRI56CriABxgbwHUvaQAfPW9m2gALJ%2Ff0hOKEvLzy6lXlx18%2B9txINr%2Bpf00lWtNSm2XibdzGXdxTpehA1RfxMDne

    Code:

    (
      $regexp := /[^a-zA-Z]/;
      $replace(Data, $regexp, "")
    )
    

    $replace function can take a regular expression as an argument. In this example, [^a-zA-Z] is matching anything that's not a letter between a-z (lower/uppercase).