ERLEDIGT
NEIN
NEIN
ANTWORTEN
6
6
ZUGRIFFE
489
489
EMPFEHLEN
-
hallo
weiß jemand wie man am besten aus einer url den host parst?(ohne Bibliothek URL zu verwenden die das ja automatisch kann) ?
thx
-
Ich würde mal auf einen geeigneten regulären Ausdruck tippen.
Gruß Stefan:-) möp
-
mm jo blos wie sieht das aus? regexp irgendwas? keine ahnung wie das geht?
kann mir niemand helfen?
-
10.10.05 23:15 #4
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/** * */ package de.tutorials; import java.net.URL; /** * @author Tom * */ public class HostFromURLExtractionExample { /** * @param args */ public static void main(String[] args) throws Exception{ System.out.println(new URL("http://www.tutorials.de/forum36").getHost()); } }
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
-
ne darf so nid sein muss ohne import java.net.URL; sein muss mit regex sein
hab auf newsgroup sowas gefunden das soll aber nid 100%ig ? wie die sagen?
Code :1 2 3 4
RE regexp; REMatch[] regexpMatch; regexp = new RE ("http://|+?/|(.*/)|.+"); regexpMatch = regexp.getAllMatches(args[0]);
-
10.10.05 23:58 #6
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Code :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
/** * */ package de.tutorials; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @author Tom * */ public class HostFromURLExtractionExample { /** * @param args */ public static void main(String[] args) throws Exception{ //In diesem Regex hab ich jetzt mal die Möglichkeit von Userkennungen (foo:bar@www.tutorials...) vernachlässigt... Matcher matcher = Pattern.compile("//([^:|/]*)?").matcher("http://www.tutorials.de:8080/forum36"); if(matcher.find()){ System.out.println(matcher.group(1)); } } }
gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
-
big thx wie geht das wenn man optional das http:// weglässt und http://www.tu... oder www.tut... schreibt so muss ja immer http:// sein?
Ähnliche Themen
-
Xml parsen
Von Astu im Forum JavaAntworten: 6Letzter Beitrag: 09.07.09, 11:39 -
Parsen
Von Nuc im Forum PHPAntworten: 7Letzter Beitrag: 17.03.09, 18:34 -
XML parsen?
Von ts230 im Forum Javascript & AjaxAntworten: 6Letzter Beitrag: 02.03.09, 04:43 -
XML Parsen mit PHP 4.3
Von wachteldonk im Forum PHPAntworten: 2Letzter Beitrag: 30.12.07, 20:37 -
PHP aus DB parsen
Von eugster im Forum PHPAntworten: 2Letzter Beitrag: 17.08.03, 14:49





Zitieren

Login





