很简单用indexOf

 
  
  1. var res = "abc#def"
  2. res.indexOf('#'); 

这样就可以了