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

Regular expressions #1

Open
filipni opened this issue Dec 3, 2020 · 0 comments
Open

Regular expressions #1

filipni opened this issue Dec 3, 2020 · 0 comments

Comments

@filipni
Copy link

filipni commented Dec 3, 2020

Try to use regular expressions when parsing text. It will make your life much easier.

AOCYJ/AOC2020/Day02.cs

Lines 35 to 40 in 66bfe87

string[] parts = line.Split(' ');
(int min, int max, char @char, string password) passwordAndPolicy;
passwordAndPolicy.min = int.Parse(parts[0].Split('-')[0]);
passwordAndPolicy.max = int.Parse(parts[0].Split('-')[1]);
passwordAndPolicy.@char = char.Parse(parts[1].Substring(0,1));
passwordAndPolicy.password = parts[2];

Interactive tutorial about regular expressions.

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

1 participant