As already mentioned by Wiktor in the comments, the easiest regular expression is
^[^.]+
The explanation from regex101.com is:
^ asserts position at start of a line
Match a single character not present in the list below [^.]+
+ Quantifier — Matches between one and unlimited times, as many times as
possible, giving back as needed (greedy)
. matches the character . literally (case sensitive)
If you are using a programming language, another possible solution is to split the string in the dot character and get the first element of the resulting array. For example:
const array1 = 'server1.mydomain.com'.split(/\./);
console.log(array1[0]);
const array2 = 'desktop-1.mydomain.com'.split(/\./);
console.log(array2[0]);
Prints:
server1
desktop-1