title: How to search/find special characters like &, < or > in the string with regex using Python
body: <p>Hi I am writing a function in python to search in a text string, with regex, for special charecters. </p>
  
  <p>Once found a match, the program should give error message and exit.</p>
  
  <p>This is what I did so far and able to search for ;,$,%,' but could not search and find characters like &amp;, &lt;, >  in windows.</p>
  
  <p>The current code given below works in windows but not in Linux. But I Want to use this code in windows as well in Linux. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>#tests for finding special characters
  
  import sys, re
  
  
  cmd = input('Enter your command : ')
  
  
  def chk_cmds(cmd):
      print('chk_cmds: lets look term at %s' % (cmd))
      msg = bool(re.search(r'\;|\$|\%|`', cmd))
      if msg is True:
          print(msg)
          print('Found a suspicious entry in the command : ' + cmd)
          print('Exiting the program')
          return -1
          sys.exit
      else:
          print('Command seems clean ' +cmd)
          return 0
      # return -1
  
  chk_cmds(cmd)
  
  </code></pre>
  
  <p>Q. How can I also also search for special characters like &amp;, &lt;, > in the strings both in windows and Linux.</p>
  
  <p>I 've tried using backslash escape character for each of those charecters </p>
  
  <p>like  <code>bool(re.search(r'\;|\$|\%|`|\&amp;|\&lt;|\&gt;', cmd))</code> but the re.search is not finding them in Windows. (and also current below code seems not working in Linux)</p>