Skip to main content
November 29, 2024
Solved

How to remove unwanted characters from text ?

  • November 29, 2024
  • 4 replies
  • 0 views

Hi ,

How to remove unwanted characters from text ?

 I get data from excel where its having char(9), char(160) sometimes different char(x) which none can expect

example: \tHello ( In Appian value : fn!char(9)Hello )

I want only Hello from the value. To use stripwith, char(160), char(10) etc.. would come in value which I can't expect

How can I achieve only wanted text or How can I remove those unwanted characters ?

Best answer by stefanhelzle0001

In the following code snippet, I just define the allowed characters. Everything else is removed.

cleanwith(
  char(9) & "Hello Worldchar" & (160),
  concat(
    char(enumerate(24) + 65), /* A-Z */
    char(enumerate(24) + 97), /* a-z */
    " "
  )
)

4 replies

stefanhelzle0001
Brainy
November 29, 2024

Did you try the function cleanwith()? In opposite to stripwith(), you define the characters to keep.

https://docs.appian.com/suite/help/24.4/fnc_text_cleanwith.html

November 29, 2024

Hi Stefan,

I have explored these functions and felt this wont help in my use case.

my use case is:

User might give tabspace or space or multiples of it along with value in the excel column which is inappropriate . I need to read the excel, get value and check the value is in my list of values. For doing this, value is coming with char(9)VALUE or char(160)VALUE etc which I cannot expect what characters the VALUE would come with. 

example

use case 1:

List of values I have in my hand: {"Hello World", "Good Morning"}

Value I'm expecting from excel :  Hello World

Excel value I received: char(9)Hello Worldchar(160)

Now I need to fetch Hello World from the excel value and check if its present in my list.
If I use stripwith(value, char(160)), next time excel value might come with char(10) which I would never know. 

stefanhelzle0001
Brainy
November 29, 2024

In the following code snippet, I just define the allowed characters. Everything else is removed.

cleanwith(
  char(9) & "Hello Worldchar" & (160),
  concat(
    char(enumerate(24) + 65), /* A-Z */
    char(enumerate(24) + 97), /* a-z */
    " "
  )
)