javascript - How to get the 1st character after a pattern using regex? -
i'm trying first character after pattern.
i.e.
border-top-color padding-top /-[a-z]/g
selects:
border[-t]op[-c]olor padding[-t]op
i want select:
border-[t]op-[c]olor padding-[t]op
how first character after selected pattern?
just use capturing group:
"border-top-color".replace(/-([a-z])/g, "-[$1]")
result:
"border-[t]op-[c]olor"
Comments
Post a Comment