We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 10 Days of Javascript
  4. Day 7: Regular Expressions I
  5. Discussions

Day 7: Regular Expressions I

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

Sort 165 Discussions, By:

recency

Please Login in order to post a comment

  • townsendTangler
    2 months ago+ 0 comments

    After reading others posts, there seem to be much better ways to do this than what I hacked together.

    see...

        var re = /^[a].+[a]$|^[e].+[e]$|^[i].+[i]$|^[o].+$[o]|^[u].+$[u]/;
        
        /*
         * Do not remove the return statement
         */
        
        return re;
    
    0|
    Permalink
  • mayanksaraswat42
    3 months ago+ 2 comments
    function regexVar() {
       
        let re = /^([aeiou]).+\1$/;
     
        return re;
    }
    
    0|
    Permalink
  • lieselu22
    4 months ago+ 1 comment
    function regexVar(s) {
       
        let re = /^([aeiou]).*\1$/i
    
        return re;
    }
    
    0|
    Permalink
  • valleriasouza28
    6 months ago+ 0 comments

    Hello everyone, I wrote this code:

    const str = "abcdo"
    let strCase
    let RegExp = /a|e|i|o|u/
    let firstLetterTest
    let lastLetterTest
    let firstLetter
    let lastLetter
    
    strCase = str.toLowerCase()
    firstLetter = strCase[0]
    lastLetter = strCase[-1]
        
    firstLetterTest = RegExp.test(firstLetter)
    lastLetterTest = RegExp.test(lastLetter)
    
    if(firstLetterTest === false ||lastLetterTest === false) {
      return console.log(false)
    } else {
    let re = strCase.startsWith(firstLetter) && strCase.endsWith(firstLetter)
    }
    

    as a solution to the problem, of course I tried to adapt it by passing str as a parameter to the function and changing the name of the function's return variable. Thanks if anyone has solutions for improvements...

    2|
    Permalink
  • tranvn98
    6 months ago+ 0 comments

    function regexVar() { /* * Declare a RegExp object variable named 're' * It must match a string that starts and ends with the same vowel (i.e., {a, e, i, o, u}) */

      let re = /^([aeiou]).*\1$/;
    /*
     * Do not remove the return statement
     */
    return re;
    

    }

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy