AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

In chatscript have function like trim() in java?

i’m using CS and interacting with FB messenger.
Anyone know remove gap function?
‘Im mortal’ -> ‘immortal’
‘skt t1 faker’ -> ‘sktt1faker’


  [ # 1 ]
Tae Hyung Kim - Apr 5, 2017:

i’m using CS and interacting with FB messenger.

if user typing id on messenger to find own information.
There are many kinds of id.
someone id is ‘sando’, ‘exam’ that is not a problem because have no gap.
but my CS bot problem occure userid have gap like ’ skt t1 faker’, ‘kt mgs’.
so i want to remove gap in userid compress string
‘kt mgs’ -> ‘ktmgs’
‘skt t1 faker’ -> ‘sktt1faker’

Is anyone else problem like me?


  [ # 2 ]

Hi Tae,

I do not think there is a trim function but there is a ^substitute function that you can use to replace the spaces.  You could make a function or outputmacro and rename it to ^trim or to ^removespaces like:

Place this at the top of your topic file:
outputmacro: ^removespaces(^text)
^substitute(character ^text ” ” “” )

Then test with this pattern:

u: (remove spaces in _* ) ^keep() ^repeat() ^removespaces(‘_0)

sample output:
HARRY:  Welcome to ChatScript.
alaric: > remove spaces in a b c



  [ # 3 ]

thanks Alaric! btw to let the initial “a” not capitalized to “A”  you maybe want to do:

^removespaces( ^original(_0) )


  [ # 4 ]

this worked for me, but I had to change your curlies for linux: 

^substitute(character ^text ” ” “” )
becomes this:
^substitute(character ^text ” ” “” )



  [ # 5 ]

it is not showing up here, but you will need to replace the curlies with your own.


  login or register to react