title: How to delete comments that are on the same line as the string i need with regex
body: <p>so im trying to separate the twitter ids into a new file to avoid clutter on the main code file but i want to be able to actually know what the heck each id is so i need to keep the comments in.</p>
  <p>iv tried a few ways to get rid of this with regex but the best iv done is just print them :/</p>
  <p>heres the code</p>
  <pre><code>for line in open(&quot;userids.txt&quot;):
      lin=re.sub(r'(?m)^ *#.*\n?', '', line)
      li=re.search(r'?!#(\w+)', lin)
      print(li)
  </code></pre>
  <p>the re.sub finds the line as a WHOLE but i want to preferably just ignore the comment entirely in one line rather than 2 like im trying here. i have tried so many different ways iv found on the internet and none work. this is the only code that even prints back the line.</p>
  <p>format in the .txt file is</p>
  <p>Twitterid #Twitterhandle</p>
  <p>but i would like it to just be</p>
  <p>Twitterid</p>