6 kyu

MAC Address : Regexp

55 of 225osofem

Description:

Given a MAC Address the purpose of this kata is to verify it's valid using regular expression.

General rule of a MAC Address is

  1. It is a string of hexadecimal digits joined together by any of :, - or .
  2. It can be strings of 2 hexadecimal digits in eight groups joined by - (e.g. 01-23-45-67-89-ab-cd-ef)
  3. It can be strings of 2 hexadecimal digits in six groups joined by - or : (e.g. 01-23-45-67-89-ab or 01:23:45:67:8f:AB)
  4. It can be strings of 4 hexadecimal digits in three groups joined by . (e.g. 0123.4567.89AB)

NOTE:

The variables $pattern and $flags will be turned into a regexp pattern using preg_match($pattern.$flags, $mac) so the beginning and ending slash "/~pattern~/" in the pattern are necessary.

Regular Expressions
Fundamentals

Stats:

CreatedApr 13, 2017
PublishedApr 13, 2017
Warriors Trained604
Total Skips65
Total Code Submissions1298
Total Times Completed225
JavaScript Completions182
PHP Completions55
Total Stars16
% of votes with a positive feedback rating90% of 81
Total "Very Satisfied" Votes69
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes4
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • osofem Avatar
  • smile67 Avatar
  • Blind4Basics Avatar
  • farhanaditya Avatar
Ad