Match the same start and end character of a string with Regex

后端 未结 4 744
醉话见心
醉话见心 2021-02-05 02:02

I\'m trying to match the start and end character of a string to be the same vowel. My regex is working in most scenarios, but failing in others:

var re = /([aeio         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 02:53

    Correct answer is already mentioned above, just for some more clarification:

    regEx= /^([a,e,i,o,u])(.*)\1$/
    

    Here, \1 is the backreference to match the same text again, you can reuse the same backreference more than once. Most regex flavors support up to 99 capturing groups and double-digit backreferences. So \99 is a valid backreference if your regex has 99 capturing groups.visit_for_detail

提交回复
热议问题