> 文档中心 > 在rebotframwork中使用正则表达式注意事项

在rebotframwork中使用正则表达式注意事项

正则表达式中单斜杠(\)的地方,在rf中需要用双斜杠表示(\)
例如在Python中通过xeger模块生成电话号码

xeger.xeger(r'(^(13\d|14[01456789]|15[012356789]|16[02356789]|17\d|18\d|19[012356789])\d{8}$)')

在rebotframwork中使用正则表达式注意事项
按原正则表达式移植到rf运行结果,直接把\d当成字符串了

    ${str}    Evaluate    xeger.xeger(r'(^(13\\d|14[01456789]|15[012356789]|16[02356789]|17\\d|18\\d|19[012356789])\\d{8}$)')    modules=xeger    ${result}    Set Variable    ${str}    #返回    [Return]    ${result}

在rebotframwork中使用正则表达式注意事项
加了双斜杠之后,正常运行
在rebotframwork中使用正则表达式注意事项

MSDN工具下载