Changes

Jump to: navigation, search

OPS102 - Regular Expressions

2 bytes removed, 17:34, 5 December 2023
Examples
|Phone Numbers||<code><nowiki>^[^+[:digit:]]*(\+?1)?[^+[:digit:]]*[2-9]([^+[:digit:]]*[0-9]){9}[^+[:digit:]]*$</nowiki></code>||(416) 967-1111<br>+1 416-736-3636<br>416-439-0000||+65 6896 2391<br>555-1212||A Canadian phone number consists of a 3-digit Area Code (which may not start with 0 or 1) and a 10-digit local number consisting of an exchange (3 digits) and a line (4 digits). The country code for Canada (and the US) is 1, so the number may be preceeded by +1 or 1. Area codes are sometimes contained in parenthesis, and dashes or spaces are sometimes used as separators.
|-
|IP Address (IPv4 dotted quad)||<code><nowiki>^((2[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9])\.){3}(2[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9])$</nowiki>|||-</code>||1.1.1.1<br>4.4.8.8<br>8.8.8.8<br>7.12.9.43<br>10.106.32.109<br>IP=100.150.200.250<br>172.16.97.1<br>192.168.0.1<br>IP=67.69.105.143||1.10.100.1000<br>255.255.255.0<br>103.271.92.16<br>1O.10.10.10||An IPv4 address in "dotted quad" notations consists of four numbers in the range 0-255 separated by periods. The numbers are called "octets" (which means a collection of eight bits, a more precise definition of a "byte").
|-
|Private IP Address||<code><nowiki>(10\.((2[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9]))|192\.168|172\.(1[6-9]|2[0-9]|3[0-1]))\.(2[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9])\.(2[0-5][0-9]|[1-2][0-9][0-9]|[1-9][0-9]|[1-9])</nowiki></code>||10.4.72.13<br>172.16.97.1<br>192.168.0.1<br>IP=192.168.113.42||1.1.1.1<br>4.4.8.8<br>192.169.12.6<br>192.168.400.37<br>Address is 1 . 2 . 3 . 4||Valid IPv4 dotted quad address with a first octet of 10; or first two octets of 192.168; or first octet of 172 followed by a second octet in the range 16-31.
|}

Navigation menu