2016-10-26 18 views
2

あなたは、このようなラスカルの文字列があります。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
visit (x) { 
    case /[\t\n]/ => "" 
} 
関連する問題