I've a code which reads the Spotify windows in order to get current song playing. The output is: Spotify - SONGNAME
How can I remove "Spotify - " using split?
How can I remove "Spotify - " using split?
string s = "there is a cat"; // // Split string on spaces. // ... This will separate all the words. // string[] words = s.Split(' '); foreach (string word in words) { Console.WriteLine(word); }
song_info = output.split(" - ")[-1]
string currentSong = "Spotify - SONGNAME"; string songTitle = currentSong.Split(" - ", 2)[1]; Console.WriteLine(songTitle);
song_info = "Spotify - SONGNAME" song_name = song_info.split(" - ")[1] # Relate it with "Spotify Plus Plus IPA"
output = "Spotify - SONGNAME" song_name = output.split("Spotify - ")[1] print(song_name)
output = "Spotify - SONGNAME" if output.startswith("Spotify - "): song_name = output.split("Spotify - ", 1)[1] else: song_name = output # in case "Spotify - " is not in the string print(song_name)
Comment