Thread Regular Expressions (19 answers)
Opened by powerburn at 2008-06-23 13:17

renee
 2008-06-23 13:29
#111355 #111355
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
C:\>perl -MYAPE::Regex::Explain -e "print YAPE::Regex::Explain->new( '^[a-z]{3,10}\s*(?:\w{3,7}?\:\/\/[\w\-\.\/]*)??\/[\w\-\.\/~%@&=+$,;]*(?:\?[\S]*)??\s*http\/\d\.\d$')->explain"
The regular expression:

(?-imsx:^[a-z]{3,10}\s*(?:\w{3,7}?\:\/\/[\w\-\.\/]*)??\/[\w\-\.\/~%@&=+$,;]*(?:\?[\S]*)??\s*http\/\d\.\d$)

matches as follows:

NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
^ the beginning of the string
----------------------------------------------------------------------
[a-z]{3,10} any character of: 'a' to 'z' (between 3
and 10 times (matching the most amount
possible))
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
(?: group, but do not capture (optional
(matching the least amount possible)):
----------------------------------------------------------------------
\w{3,7}? word characters (a-z, A-Z, 0-9, _)
(between 3 and 7 times (matching the
least amount possible))
----------------------------------------------------------------------
\: ':'
----------------------------------------------------------------------
\/ '/'
----------------------------------------------------------------------
\/ '/'
----------------------------------------------------------------------
[\w\-\.\/]* any character of: word characters (a-z,
A-Z, 0-9, _), '\-', '\.', '\/' (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
)?? end of grouping
----------------------------------------------------------------------
\/ '/'
----------------------------------------------------------------------
[\w\-\.\/~%@&=+$,;]* any character of: word characters (a-z, A-
Z, 0-9, _), '\-', '\.', '\/', '~', '%',
'@', '&', '=', '+', '$', ',', ';' (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
(?: group, but do not capture (optional
(matching the least amount possible)):
----------------------------------------------------------------------
\? '?'
----------------------------------------------------------------------
[\S]* any character of: non-whitespace (all
but \n, \r, \t, \f, and " ") (0 or more
times (matching the most amount
possible))
----------------------------------------------------------------------
)?? end of grouping
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
http 'http'
----------------------------------------------------------------------
\/ '/'
----------------------------------------------------------------------
\d digits (0-9)
----------------------------------------------------------------------
\. '.'
----------------------------------------------------------------------
\d digits (0-9)
----------------------------------------------------------------------
$ before an optional \n, and the end of the
string
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Regular Expressions