Capture data to space, regex

1

I'm using this regular expression to capture data between asterisks:

\*(.+)\*

however, it mistakenly captures when the text is filled with asterisks, for example:

oi pessoas *lindas* e pessoas *lindos* 

It understands only asterisks outside capturing all lindas* e pessoas *lindos being that it was only to capture lindas and lindos separately.

Is there any way to adapt it so that it can be taken separately? Using some condition with space or something ..?

    
asked by anonymous 18.02.2018 / 13:46

1 answer

4

You can use \w+ to indicate that there are only letters between asterisks:

the expression: \*(\w+)\*

see working on Regex101

    
18.02.2018 / 13:54