Created
          April 4, 2019 13:11 
        
      - 
      
- 
        Save martinhj/502334e63c1e891565fa8627d3b29538 to your computer and use it in GitHub Desktop. 
    Javascript lookahead & -behind
  
        
  
    
      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
    
  
  
    
  | // positive lookahead | |
| // ?= | |
| const lookaheadRegex = /something(?=\$)/ // match something at end of line, but not the end of line | |
| // positive lookbehind | |
| // ?<= | |
| const lookaheadRegex = /(?<=\^)something/ // match something at the start of line, but not the start of line | |
| // negative lookahead | |
| // ?! | |
| const lookaheadRegex = /something(?!\$)/ // match something not at the end of line | |
| // negative lookbehind | |
| // ?<! | |
| const lookaheadRegex = /(?<!\^)something/ // match something not at the start of line | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment