Hergine Richemont

Learning just for the fun of it

Regular expressions

C# Track, Exercism #46 Parsing Log Files

Relevant link


Github solution: exercism-solutions/parsing-log-files

Exercism #46: Parsing Log Files

Learning Goal

Regular Expressions

Relevant Information

Processing of regular expressions are handled using the Regex class

Task 1:  Identify garbled log lines

To determine if the logs contains one of these at the beginning: [TRC][DBG][INF][WRN][ERR][FTL] I used the IsMatch() method

Task 2: Split the log line

To split the Log files that contains a first character of “<” and a last character of “>” and any combination of the following characters “^”, “*”, “=” and “-” in between replacing them with a comma and splitting the string into an array of strings, I used pattern recognition, the Replace() method to replace the pattern and the split method to give an array.

Task 3: Count the number of lines containing a quoted password

To count the number of quoted passwords defined as a string enclosed in double quotes, is case sensitive and can have other content between the quotes, I used the method Matches().

Task 4: Remove artifacts from log

To remove the end of line text a line ended by a number without intervening spaces from the given line using Regex and replace it by a clean string I used the Replace() method.

Task 5: List lines with extremely weak passwords so the guilty can be punished

I spotted weak password using pattern recognition in a Match instance.

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted