Get servername from a given url?
BlitzMax Forums/BlitzMax Beginners Area/Get servername from a given url?
| ||
| Hello guys! I'm looking for a fast function to extract the servername from a given url... Example: "http://www.blitzbasic.com/Community/_search.php?bbs=BlitzMax&forum=&terms=url&method=advanced&case=no&results=topic&user=&submit=Search" Returns: "www.blitzbasic.com" Don't want to re-invent the wheel here. Grisu |
| ||
| wxURI ? :-p Maybe there's some code in the archives? |
| ||
| Haven't found such a code via a forum search. wx? I don't need a whole module... :) Where can I get that stuff? |
| ||
| Fair enough :-) (just that you said you didn't want to re-invent wheels) I'm sure it's not that difficult to parse and get the info you need. |
| ||
Print getBaseURL("http://www.blitzbasic.com/Community/_search.php?bbs=BlitzMax&forum=&terms=url&method=advanced&case=no&results=topic&user=&submit=Search")
Print getBaseURL("www.blitzbasic.com/Community/_search.php?bbs=BlitzMax&forum=&terms=url&method=advanced&case=no&results=topic&user=&submit=Search")
Print getBaseURL("file://www.blitzbasic.com?bbs=BlitzMax&forum=&terms=url&method=advanced&case=no&results=topic&user=&submit=Search")
Function getBaseURL:String( url:String )
Local noProtocol:String
Local a:String[] = url.split("://")
If a.length>1
noProtocol = a[1]
Else
noProtocol = a[0]
EndIf
Return noProtocol.split("/")[0].split("?")[0]
EndFunction |
| ||
| That's more compact than anything else I've come up with so far. :( Thanks a lot Fredborg! |