Capture data into space, regex

Asked

Viewed 102 times

1

I am using this regular expression to capture data between asterisks:

\*(.+)\*

however it miscaptures when the text is filled with asterisks, for example in:

oi pessoas *lindas* e pessoas *lindos* 

she understands only the most external asterisks capturing all the lindas* e pessoas *lindos being that it was to capture only lindas and lindos separately.

Is there any way to adapt it so that it picks up separately? Using some space condition or something..?

1 answer

4


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

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

see working on Regex101

  • https://regexr.com/3kvab for everything (numbers and letters)

  • would be like instead of specifying what I want, specify what I would not like? Like leave everything but space

  • 2

    @user3163662 Yes. Just add ^ inside the brackets.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.