如何从Rascal中的字符串中删除空格?

时间:2016-10-26 08:46:32

标签: string whitespace trim rascal

当您在Rascal中有一个字符串时,这样:

"\n\tThis is a specification of a toy Transaction.\n\tVia a transaction money
can be transfered between two accounts\n"

或者

        This is a specification of a toy Transaction.
        Via a transaction money can be transfered between two accounts

如何删除字符串中间的空格?

我现在的解决方案是调用一个替换'\ n','\ t'和'\ r'的函数,但这似乎不是一个可持续的解决方案。此外,函数trim仅删除开头和结尾的空格。

1 个答案:

答案 0 :(得分:1)

visit (x) { 
  case /[\t\n]/ => "" 
}
相关问题