Nov 6, 2015, 7:29 AM
Post #1 of 2
I would like to remove everything that comes after a backslash, but it seems like the backslash is giving me trouble. For example,
Remove everything after a backslash
I have: servername\hostname
want to end up with: servername
I am using the following command:
$word = "servername\hostname";
$word =~ s/\\.*$//g;
but I end up with: servernamehostname.
Its very confusing because when I use the same command but just change everything to forward slashes it works just fine. Something different must be needed. I also tried doing a split, but the same thing occurred. The split just removed the slash and combined server and hostname. I'm sure there is a simple answer, any suggestions anyone could provide would be much appreciated.