i have a site collection called
is there anyway to get the first bit
https://mysitedev.sharepoint.com with csom. will i have to do it with regex?
As per my knowledge you can not get the tenant site collection url directly.
You can get it by splitting the url by .(dot) and then concatenate firstPart [https://mydevsite] + secondPart [sharepoint] + thirdPart [com]