Created
          April 1, 2015 00:00 
        
      - 
      
- 
        Save zephyrfalcon/f828d49ee653f3bf686a to your computer and use it in GitHub Desktop. 
    ooc: Adding split() method to Regexp 
  
        
  
    
      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
    
  
  
    
  | import text/Regexp | |
| import structs/ArrayList | |
| extend Regexp { | |
| split: func (s: String) -> ArrayList<String> { | |
| results := ArrayList<String> new() | |
| while (true) { | |
| matchobj := this matches(s) | |
| if (matchobj == null) break | |
| token := matchobj group(0) | |
| cutoff := matchobj groupStart(0) + matchobj groupLength(0) | |
| results add(token) | |
| s = s substring(cutoff) | |
| } | |
| return results | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment