Skip to content

Commit

Permalink
continue regex exercice
Browse files Browse the repository at this point in the history
  • Loading branch information
romaincarlier4 committed Oct 26, 2023
1 parent 54925e0 commit b8c874a
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions Regex/run
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,42 @@ regex2=$(cat student_regex2)
regex3=$(cat student_regex3)
regex4=$(cat student_regex4)

output1=$(grep -oP $regex1 apache.log)
good_output1=$(grep -oP '(\d{1,3}\.){3}\d{1,3}' apache.log)
grep -oP $regex1 apache.log > student_result1
grep -oP '(\d{1,3}\.){3}\d{1,3}' apache.log > good_result1

if [ $output1 == $good_output1 ]; then
if diff student_result1 good_result1; then
feedback-result --id regex1 success
feedback-msg -em "Bravo"
else
feedback-result --id regex1 failed
feedback-msg -em "Résultat de votre programme : $output1"
fi

output2=$(grep -oP $regex2 apache.log)
good_output2=$(grep -oP '\[.*?\]' apache.log)
grep -oP $regex2 apache.log > student_result2
grep -oP '\[.*?\]' apache.log > good_result2

if [ $output2 == $good_output2 ]; then
if diff student_result2 good_result2; then
feedback-result --id regex2 success
feedback-msg -em "Bravo"
else
feedback-result --id regex2 failed
feedback-msg -em "Résultat de votre programme : $output2"
fi

output3=$(grep -oP $regex3 apache.log)
good_output3=$(grep -oP '"GET\s.*?"' apache.log)
grep -oP $regex3 apache.log > student_result3
grep -oP '"GET\s.*?"' apache.log > good_result3

if [ $output3 == $good_output3 ]; then
if diff student_result3 good_result3; then
feedback-result --id regex3 success
feedback-msg -em "Bravo"
else
feedback-result --id regex3 failed
feedback-msg -em "Résultat de votre programme : $output3"
fi

output4=$(grep -oP $regex4 apache.log)
good_output4=$(grep -oP '^.*200.*$' apache.log)
grep -oP $regex4 apache.log > student_result4
grep -oP '^.*200.*$' apache.log > good_result4

if [ $output4 == $good_output4 ]; then
if diff student_result4 good_result4; then
feedback-result --id regex4 success
feedback-msg -em "Bravo"
else
feedback-result --id regex4 failed
feedback-msg -em "Résultat de votre programme : $output4"
fi

0 comments on commit b8c874a

Please sign in to comment.