Of the following please explain exactly how the three regula

Of the following please explain exactly how the three regular expressions in python work:

1. \\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b

2. \\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b

3. \\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b

Solution

1) \\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b

This accepts numbers between 0 to 3 and should place dot between these integers.

Eg: 12.12.12.12
123.122.123.123

------------------------------------------------------------------------------------------------------------------------------------------------------------------

2)

25[0-5] --> 25 matches the characters 25.
[0-5] -> a sinle character range between Ascii value 48 and Ascii 53.
[0-4] -> single character range between Ascii value 48 - 52
[0-9] -> single character range between Ascii value 48 - 57

Matching string: 123.122.123.123

----------------------------------------------------------------------------------------------------------------------------------------------------------------

3)

This regex also same where it accepts only upto 3 chars before \'.\' char.

Matching pattern

12.12.12.12
123.122.123.123
19.10.19.18
101.23.23.23

Of the following please explain exactly how the three regular expressions in python work: 1. \\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b 2. \\b(25[0-5]|2[0-

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site