Created
          September 22, 2013 08:01 
        
      - 
      
- 
        Save smallnewer/6657798 to your computer and use it in GitHub Desktop. 
    以特殊符号分割指定字符串。具体描述见评论
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Document</title> | |
| </head> | |
| <body> | |
| <div>\||di\|v|ab\@ca@大点的a:吧啊</div> | |
| <script> | |
| var str = document.querySelector("div").innerHTML; | |
| // alert(str) | |
| var reg = /((?:.*?(?:\\[\|\:\@])*)[^\\]*?)([\|\:\@]|[^\|\:\@]$)/gi; | |
| var ret = []; | |
| var length = str.length; | |
| str.replace(reg,function ($,$1,$2,ind) { | |
| console.log(arguments); | |
| if (ind + $.length < length) { | |
| $ = $.slice(0,-1); | |
| }; | |
| ret.push($); | |
| }) | |
| console.log(ret); | |
| </script> | |
| </body> | |
| </html> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
上述代码尚未完成,暂作记录