Schrift
[thread]12062[/thread]

Regular Expressions

Leser: 1


<< |< 1 2 >| >> 20 Einträge, 2 Seiten
powerburn
 2008-06-23 13:17
#111354 #111354
User since
2008-06-23
8 Artikel
BenutzerIn
[default_avatar]
Hallo Leute!

Ich bräuchte bitte Hilfe bzw. eine kleine Erklärung zu einer Regular Expression:

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

Was heißt das genau?! :)

Danke im vorhinein.
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/
powerburn
 2008-06-23 14:01
#111358 #111358
User since
2008-06-23
8 Artikel
BenutzerIn
[default_avatar]
super danke!

gibts im internet irgendwelche tools in regex in so eine explanation umwandeln?!
renee
 2008-06-23 14:02
#111359 #111359
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
CPAN:YAPE::Regex::Explain
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/
moritz
 2008-06-23 14:30
#111361 #111361
User since
2007-05-11
923 Artikel
HausmeisterIn
[Homepage]
user image
renee+2008-06-23 11:29:33--
Code: (dl )
    \w{3,7}?                 word characters (a-z, A-Z, 0-9, _)


Das ist bei Textstrings schlichtweg falsch. Da umfass \w deutlich mehr.
(Ich weiss dass nicht renee daran schuld ist...)
GwenDragon
 2008-06-23 15:18
#111364 #111364
User since
2005-01-17
14598 Artikel
Admin1
[Homepage]
user image
Quote
Das ist bei Textstrings schlichtweg falsch. Da umfass \w deutlich mehr.
Kommt doch auch noch darauf an, ob es UTF ist oder welche locales verwendet werden, oder?
moritz
 2008-06-23 16:09
#111366 #111366
User since
2007-05-11
923 Artikel
HausmeisterIn
[Homepage]
user image
GwenDragon+2008-06-23 13:18:11--
Quote
Das ist bei Textstrings schlichtweg falsch. Da umfass \w deutlich mehr.
Kommt doch auch noch darauf an, ob es UTF ist oder welche locales verwendet werden, oder?


Es hängt nicht davon ab, es UTF-8 ist oder nicht. Textstrings können perl-intern auch als latin-1 gespeichert werden.

\w ist glaube ich auch locale-abhängig, aber locales würde ich meiden wo immer es geht. Die Unicode-Version von \w ist schon ganz ordentlich, und tut eigentlich fast immer das, was man will.
powerburn
 2008-06-24 13:41
#111412 #111412
User since
2008-06-23
8 Artikel
BenutzerIn
[default_avatar]
Bitte um Hilfe bei den nächsten RegExp.

1. (?!$|\W|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})
2. u[fF]{2}[0-9a-fA-F]{2}
#Kein Kommentar
 2008-06-24 20:42
#111470 #111470
User since
2007-06-09
575 Artikel
HausmeisterIn
[default_avatar]
renee+2008-06-23 12:02:56--
CPAN:YAPE::Regex::Explain
Gerade weil wir alle in einem Boot sitzen, sollten wir froh sein, dass nicht alle auf unserer Seite sind
powerburn
 2008-06-25 09:24
#111480 #111480
User since
2008-06-23
8 Artikel
BenutzerIn
[default_avatar]
hab jetzt einen perl compiler gesaugt... weiß nicht ob der was kann oder zu etwas taugt... sagt ihr es mir bitte...
ActivePerl-5.6.1.633-MSWin32-x86

jedenfalls wenn ich das test.pl ausführen will von dem regex zeigt er mir folgenden error an:

BEGIN failed--compilation aborted at test.pl at line 13
<< |< 1 2 >| >> 20 Einträge, 2 Seiten



View all threads created 2008-06-23 13:17.