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?

example here! :)

just use capturing group:

"border-top-color".replace(/-([a-z])/g, "-[$1]") 

result:

"border-[t]op-[c]olor" 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -