Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constant regex has extra escape slash #2

Open
tirthb opened this issue Nov 19, 2017 · 3 comments
Open

constant regex has extra escape slash #2

tirthb opened this issue Nov 19, 2017 · 3 comments

Comments

@tirthb
Copy link

tirthb commented Nov 19, 2017

The original regex was [1-2][0-9]{3}\-[0-1][0-9]\-[0-3][0-9]

But the contant regex in the general sol had an extra escape character.
string public constant regex = "[1-2][0-9]{3}\\-[0-1][0-9]\-[0-3][0-9]";

@gnidan
Copy link
Owner

gnidan commented Nov 19, 2017

I don't see the difference between your two examples? The string should have extra escape characters for the constant to appear properly.

Is the matching behavior broken? Or is the problem just with the constant?

@tirthb
Copy link
Author

tirthb commented Nov 20, 2017

I edited the comment above. Yes, the problem is only with the constant having an extra backslash. Only the first one.

@cds-amal
Copy link

You need to escape the backslash in a solidity string literal. For example:

ParserError: Expected string end-quote.
  |
  |         const foo = "\";
  |                     ^^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants