c# - Split a string so that it loses http:// and anything after the '.' -
i need parse url server shows "na30" when i'm doing split cant seem na30. have tried trimming '.' , '/' , think i'm getting array parts wrong. guidance?
link https://na30.salesforce.com
what i'm working on
string thisurl; if (helper.instanceurl.contains(@"://")) { thisurl = helper.instanceurl.split(new[] { "://" }, 2, stringsplitoptions.none)[1]; return thisurl.split('/')[0].split('.')[0]; } return "";
you can find string uri class
uri u = new uri("https://na30.salesforce.com"); console.writeline(u.host.split('.')[0]);
a worth question read what's difference between uri.host , uri.authority
Comments
Post a Comment