3.0 KiB
3.0 KiB
Hints
General
- Review regular expression patterns from the introduction. Remember, when creating the pattern a string, you must escape some characters.
- Read about the
Regex
module in the documentation. - Read about the regular expression sigil in the Getting Started guide.
- Check out this website about regular expressions: Regular-Expressions.info.
- Check out this website about regular expressions: Rex Egg - The world's most tyrannosauical regex tutorial.
- Check out this website about regular expressions: RegexOne - Learn Regular Expressions with simple, interactive exercises.
- Check out this website about regular expressions: Regular Expressions 101 - an online regex sandbox.
- Check out this website about regular expressions: RegExr - an online regex sandbox.
1. Identify garbled log lines
- Use the
r
sigil to create a regular expression. - There is an operator that can be used to check a string against a regular expression. There is also a
Regex
function and aString
function that can do the same. - Don't forget to escape characters that have special meaning in regular expressions.
2. Split the log line
- There is a
Regex
function as well as aString
function that can split a string into a list of strings based on a regular expression. - Don't forget to escape characters that have special meaning in regular expressions.
3. Remove artifacts from log
- There is a
Regex
function as well as aString
function that can change a part of a string that matches a given regular expression to a different string. - There is a modifier that can make the whole regular expression case-insensitive.
4. Tag lines with user names
- There is a
Regex
function that runs a regular expression against a string and returns all captures.