Decription
Ihr Beispieltext gegeben ...
http://steamcommunity.com/id/rasmusvejby/
http://steamcommunity.com/profiles/76561198040893433
... diese Regex ...
^https?://(?:www\.)?steamcommunity\.com/(id/([^/\s]*)|profiles/([^/\s]*))
... wird die folgenden
tun
- validieren Sie die URL enthält
steamcommunity.com
- Matches mit oder ohne die führende
www
- Ermöglicht
http
oder https
- fängt die ID oder Profil-Teil der URL
- fängt die Zeichenfolge für die ID oder Profil
Capture-Gruppen
- Gruppe 0 erhält die vollständige Zeichenfolge
- Gruppe 1 erhält die (ID oder Profile) und den zugehörigen Wert
- Gruppe 2
- Gruppe 3 erhält nur den Wert der ID wird nur den Wert des Profils
Beispiel
Beispielspiele
[0][0] = http://steamcommunity.com/id/rasmusvejby
[0][1] = id/rasmusvejby
[0][2] = rasmusvejby
[0][3] =
[1][0] = http://steamcommunity.com/profiles/76561198040893433
[1][1] = profiles/76561198040893433
[1][2] =
[1][3] = 76561198040893433
Erklärung
NODE EXPLANATION
----------------------------------------------------------------------
^ the beginning of a "line"
----------------------------------------------------------------------
http 'http'
----------------------------------------------------------------------
s? with or without 's'
----------------------------------------------------------------------
:// '://'
----------------------------------------------------------------------
(?: group, but do not capture (optional
(matching the most amount possible)):
----------------------------------------------------------------------
www 'www'
----------------------------------------------------------------------
\. '.'
----------------------------------------------------------------------
)? end of grouping
----------------------------------------------------------------------
steamcommunity 'steamcommunity'
----------------------------------------------------------------------
\. '.'
----------------------------------------------------------------------
com/ 'com/'
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
id/ 'id/'
----------------------------------------------------------------------
( group and capture to \2:
----------------------------------------------------------------------
[^/\s]* any character except: '/', whitespace
(\n, \r, \t, \f, and " ") (0 or more
times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \2
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
profiles/ 'profiles/'
----------------------------------------------------------------------
( group and capture to \3:
----------------------------------------------------------------------
[^/\s]* any character except: '/', whitespace
(\n, \r, \t, \f, and " ") (0 or more
times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \3
----------------------------------------------------------------------
) end of \1
@ nhouser9 Ich weiß nicht, wo ich anfangen soll. Das ist ziemlich viel, wonach ich suche, wie ich anfangen soll. –
Dann sollten Sie auf Google für Tutorials auf Regex suchen, nicht nur StackOverflow bitten, Ihre Arbeit für Sie zu erledigen.Wir helfen Ihnen bei bestimmten Problemen, sind aber nicht dazu da, Ihren Code einfach zu schreiben. – nhouser9