如何匹配语句中的单词

时间:2018-03-07 15:53:27

标签: regex robotframework

我无法使用RTP_SS_RUNNING找到should_match_regexpNAME STATUS -------------------------------------------------------------------------------- AAAA XXX_SS_RUNNING YYYYYY XXX_SS_RUNNING ZZZZ XXX_SS_RUNNING AA XXX_SS_RUNNING MMMMMM XXX_SS_RUNNING NNNN XXX_SS_RUNNING PPPPPP XXX_SS_RUNNING 来自下方输出的机器人框架。

register_rest_field

1 个答案:

答案 0 :(得分:0)

检查以下解决方案:

*** Settings ***
Library     OperatingSystem

*** Test Cases ***
Valid Login
    ${str} =    Get File    val.txt
    ${match}    ${group1}   ${group2}=  
    ... Should Match Regexp ${str}  (AAAA)\\s+(.*)
    Log ${group1}
    Log ${group2}

Output

如果你正在做同样的事情并且你的正则表达式不匹配,那么你可能会错过以下点:

Backslash is an escape character in the test data, and possible backslashes in the pattern must thus be escaped with another backslash (e.g. \\d\\w+).