Last active
          March 7, 2024 06:24 
        
      - 
      
- 
        Save bethropolis/8a246c9f4216b0626ffeae7f2de1403a to your computer and use it in GitHub Desktop. 
    judul ishura
  
        
  
    
      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
    
  
  
    
  | // HTML snippet | |
| const htmlSnippet = ` | |
| <div class="infozingle"> | |
| <p> | |
| <span> | |
| <b>Judul</b>: Ishura | |
| </span> | |
| </p> | |
| </div> | |
| `; | |
| // REGEX | |
| const regexPattern = /<b>(.*?)<\/b>:\s*(.*)/; | |
| const matches = htmlSnippet.match(regexPattern); | |
| if (matches) { | |
| const fullName = matches[1] + " " + matches[2]; | |
| console.log(fullName); | |
| } else { | |
| console.log("No match found."); | |
| } | |
| // USING DOM | |
| const parser = new DOMParser(); | |
| const doc = parser.parseFromString(htmlSnippet, 'text/html'); | |
| const spanText = doc.querySelector('.infozingle span').textContent.trim(); | |
| console.log(spanText); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment