Currently, I’m getting problem to match two strings using Should Match Regexp when one of than (or both) has the sub-string “\R” or “\P” like C:\Retail\Software\POSusb\ or C:\Program Files\WNPOS\ .
Someone have idea how could I match the following strings without bad scape error?
CODE:
#bad_escape_sample.robot
*** Settings ***
Library BuiltIn
*** Test Cases ***
Bad Scape R
${string_1}= Set Variable "prefixesC:\\Retail\\Software\\POSusb\\postfixes"
${string_2}= Set Variable "[\x00-\x7F]*C:\\Retail\\Software\\POSusb\\[\x00-\x7F]*"
Should Match Regexp ${string_1} ${string_2}
Bad Scape P
${string_1}= Set Variable "prefixesC:\\Program Files\\WNPOS\\postfixes"
${string_2}= Set Variable "[\x00-\x7F]*C:\\Program Files\\WNPOS\\[\x00-\x7F]*"
Should Match Regexp ${string_1} ${string_2}
Thank you very much Dave . The problem was solved after following your solution.
#bad_escape_sample_solved.robot
*** Settings ***
Library BuiltIn
*** Test Cases ***
Bad Scape R - damies13 Dave Solution
${string_1}= Set Variable "prefixesC:\\Retail\\Software\\POSusb\\postfixes"
${string_2}= Set Variable "[\\x00-\\x7F]*C:\\\\Retail\\\\Software\\\\POSusb\\\\[\\x00-\\x7F]*"
Should Match Regexp ${string_1} ${string_2}
Bad Scape P - damies13 Dave Solution
${string_1}= Set Variable "prefixesC:\\Program Files\\WNPOS\\postfixes"
${string_2}= Set Variable "[\\x00-\\x7F]*C:\\\\Program Files\\\\WNPOS\\\\[\\x00-\\x7F]*"
Should Match Regexp ${string_1} ${string_2}