I cannot use the match function if I try to escape doubles quotes with backslashes.
example:
".*?input type=/"hidden/" value=/"([0-9a-f]+?)/" name=/"csrf/".*"
everything gets weired after the second double quote.
parsing quotes in match function
Moderator: Martin
Re: parsing quotes in match function
Hi,
Double quotes in a string should be escaped using a backslash, not a forward slash:
s = ".*?input type=\"hidden\" value=\"([0-9a-f]+?)\" name=\"csrf\".*";
You can also use single-quotes to enclose the string. This has the advantage that double quotes don't need to be escaped (and it avoids that inline-expressions in string literals like {a} are replaced, which could be used in some regular expressions):
s = '.*?input type="hidden" value="([0-9a-f]+?)" name="csrf".*';
Regards,
Martin
Double quotes in a string should be escaped using a backslash, not a forward slash:
s = ".*?input type=\"hidden\" value=\"([0-9a-f]+?)\" name=\"csrf\".*";
You can also use single-quotes to enclose the string. This has the advantage that double quotes don't need to be escaped (and it avoids that inline-expressions in string literals like {a} are replaced, which could be used in some regular expressions):
s = '.*?input type="hidden" value="([0-9a-f]+?)" name="csrf".*';
Regards,
Martin