如何在机器人框架中用空格替换所有转义序列

时间:2018-02-09 10:38:57

标签: robotframework

我尝试了多种方法将包含转义序列字符的变量转换为空字符串。如何用空格替换和转义序列字符?

${stg}    Set Variable    \r\n
Replace String    ${stg}    \r\n    ${EMPTY}
Log     ${stg}
Should Not Be Equal    ${stg}    \r\n

在第4行,$ {stg} =='\ r \ n'。我如何将其留空?

1 个答案:

答案 0 :(得分:2)

你非常接近,替换字符串的文档给你答案:

        A modified version of the string is returned and the original
    string is not altered.

    Examples:
    | ${str} =        | Replace String | Hello, world!  | world | tellus   |
    | Should Be Equal | ${str}         | Hello, tellus! |       |          |

在您的情况下,将第2行的返回分配到$ {stg}:

${stg}  Replace String    ${stg}    \r\n    ${EMPTY}