
binary0101
New User
Nov 6, 2015, 7:29 AM
Post #1 of 2
(1052 views)
|
Remove everything after a backslash
|
Can't Post
|
|
I would like to remove everything that comes after a backslash, but it seems like the backslash is giving me trouble. For example, I have: servername\hostname want to end up with: servername I am using the following command: $word = "servername\hostname"; $word =~ s/\\.*$//g; print "$word\n"; 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. THANKS!!!
|