1,885
edits
Changes
no edit summary
[[Category:OPS102]]{{Chris Tyler Draft}}'''Regular Expressions''' are search patterns for "Regular Text". They are used by many different tools and languages, including the Linux grep command, the Windows findstr command, less, vi/vim, sed, awk, perl, python, and many others.
== Why Use Regular Expressions? ==
!Description!!Regexp!!Matches!!Does not match!!Comments
|-
|WordA specific word||<code><nowiki>Hello</nowiki></code>||hello Hello<br>Hello there!<br>Hello, World!<br>He said, "Hello James", in a very threatening tone||Hi there<br>Hell Of of a Day<br>h el lo||
|-
|IP Address (IPv4 dotted quad)A specific word with nothing else on the line||<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])^Hello$</nowiki></code>||Hello there!<br>Hello, World!<br>He said, "Hello James", in a very threatening tone<br>Hi there<br>Hell of a Day<br>h el lo||
|-
|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.
|}