Regex
Work through every question currently mapped to this canonical topic.
- Extract all the numbers
Answer
- "\d+"
- Extract the first word of each line
Answer
"^\w+" Bonus: extract the last word of each line
- "\w+(?=\W*$)" (in most cases, depends on line formatting)
- Extract all the IP addresses
Answer
- "\b(?:\d{1,3}\ .){3}\d{1,3}\b" IPV4:(This format looks for 1 to 3 digit sequence 3 times)
- Extract dates in the format of yyyy-mm-dd or yyyy-dd-mm
🚧 Answer not written yet.
- Extract email addresses
Answer
- "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\ .[A-Za-z]{2,}\b"
- Replace tabs with four spaces
🚧 Answer not written yet.
- Replace 'red' with 'green'
🚧 Answer not written yet.