Attention: Answers.ros.org is deprecated as of August the 11th, 2023. Please visit robotics.stackexchange.com to ask a new question. This site will remain online in read-only mode during the transition and into the foreseeable future. Selected questions and answers have been migrated, and redirects have been put in place to direct users to the corresponding questions on Robotics Stack Exchange. Additional details are available here.
The command should be sudo apt-get purge '^ros-*', to match really only things that start with ros-, otherwise it will uninstall other packages that contain the string ros, like things with microsoft in the name (this is probably also the answer to your problem, @aidos).