ATTENTION:
Test for using regularexpressions in C(++);
Since the GNU extensions did not work I had to use the Posix Regex Functions.
Here are some examples for test and use:
/////////////////////////////////////////////////////////////////////////////
//
// matching for videomachines: [second][second]:[frames][frames]
// where frames can maximal be 24
//
/////////////////////////////////////////////////////////////////////////////
a
aa
1
12
123
12:
12::
12::1
12:1
12:10
12:101
99:24
99:25
Matches single inputs:
^[0-9]{0,2}(:?)(([0-9]$)|([0-1][0-9]$)|([2][0-4]$))
Matches the whole:
^([0-9]?[0-9]):(([0-1][0-9]$)|([0-9]$)|([2][0-4]$))
/////////////////////////////////////////////////////////////////////////////
//
// matching for hardwareaddresses eg.: 00:02:44:37:7e:fd
//
/////////////////////////////////////////////////////////////////////////////
0:2:44:37:7e:fd
00:02:44:37:7e:fd
00:23:A3:11:FF:78
00:23:a3:11:ff:78
Pattern:
--------
^((([0-9 a-f A-F]{1,2}:){5})[0-9 a-f A-F]{1,2})$
/////////////////////////////////////////////////////////////////////////////
//
// matching of IP4 ip addresses
//
/////////////////////////////////////////////////////////////////////////////
Gesamte IpAdresse:
-----------------
^(([1]?[0-9]?[0-9]\.)|([2][0-5][0-5]\.)){3}(([1]?[0-9]?[0-9])|([2][0-5][0-5]))$
Eingabe IpAdresse:
------------------
(^(([1]?[1-9]?[0-9])|([2][0-5][0-5]))$)|(^((([1]?[1-9]?[0-9]\.)|([2][0-5][0-5])\.)){1,3}(([0-1]?[0-9]?[0-9])|([2][0-5][0-5]))?$)
127.0.1.0
192.168.0.20
255.255.255.0
256.255.224.88
10.20.0.122
10.20.0.122ddd
10.20.0.122222
2.12.133.9
.....
/////////////////////////////////////////////////////////////////////////////
//
// Others
//
/////////////////////////////////////////////////////////////////////////////
- Email validity, will only match email addresses which are valid, for instance user@host.com:
[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+
- Email validity #2, matches email addresses with a name in front, for instance "Joe Doe ":
("?[a-zA-Z]+"?[ \t]*)+\<[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+\>
- Protocol validity, matches web based protocols such as htpp://, ftp:// or https:// :
[a-z]+://
- C/C++ includes, matches valid include statements in C/C++ files:
^#include[ \t]+[<"][^>"]+[">]
- C++ end of line comments:
//.+$
- C/C++ span line comments, it has one flaw, can you spot it?:
/\*[^*]*\*/
- Floating point numbers, matches simple floating point numbers of the kind 1.2 and 0.5:
-?[0-9]+\.[0-9]+
Hexadecimal numbers, matches C/C++ style hex numbers, 0xcafebabe
0x[0-9a-fA-F]+