What is the difference between using the two following statements in a cucumber step definition? When I tested them in Rubular, they both worked in all the cases I could imagine. In the case of the second, my syntax highlighting is more likely to look good (no extra double quote to mess things up).
Even in the Stack Overflow syntax highlighting, it gets goofed up on the first. What are the advantages of the more common first example?
Given /^My name is "([^"]*)"$/ do |myname|
Given /^My name is "(.+)"$/ do |myname|
[^”]* means N (N>=0) characters except “
.+ means N (N>0) characters including “
If the subject is more than 1 char, and without quote mark(“), the two regex patterns are equal.
But, consider this string:
My name is "special_name_contain_"_laugh"Run your pattern again, they are NOT the same 🙂