'Should Match Regexp' failed: SyntaxError: invalid syntax (<string>, line 1)

Hi,

I get some trouble using Should Match Regexp
I got the error:
'Should Match Regexp' failed: SyntaxError: invalid syntax (<string>, line 1)
I don’t see what’s wrong with my string “${countryValue}”

Any idea?

It looks like you are trying to do an inline call to the keyword within the IF statement. At this time this is not allowed. So instead of

IF    Should Match Regexp    ${countryValue}    [A-Z]{3}
    [Return]    ${True}

one would generally call the keyword first saving the result and then perform a check. I’ll note in this case the Should Match Regex is a validation keyword that fails if no match. So to get the same behavior as your keyword I tried this,

Validate traffic data
    [Arguments]  ${traffic_data}
   ${countryValue}=    Get Value From JSON    ${traffic_data}    $.country 

   ${isMatch}=  Run Keyword and Return Status  Should Match Regexp    ${countryValue}    [A-Z]{3}
   [Return]  ${isMatch}