RegEx - get only last asterisk

239 views Asked by At

Is it possible to do a RegEx to only match the last asterisk right before and first asterisk right after an value?

Value: **example**

My actual regex: /\*(.*?)\*/g

My actual regex matches the two asterisks before and after word example, but i want to do a regex that only matches the last asterisk right before and the first asterisk right after the word.

Thank you!

1

There are 1 answers

2
Our_Benefactors On BEST ANSWER

try /[*][^*]+[*]/gm

Works as tested on regex101.com