RegEx Match Asterisk *

Hi everyone, i would like to parse the Asterisk Sign * within a Text using RegEx.

^(\\*).*?

This code will not match. How to realize that?

Thanks and Greetings.

that only matches a single * at the beginning of a line
is that what you want ?

[quote=321541:@Norman Palardy]that only matches at the beginning of a line
is that what you want ?[/quote]
No Norman, here is a example Text “My favorite* honey”. “favorite” should be matched.

^.*(?:(.*)\\*)?.*$

Have you tried this in Kem’s RegExRX Tool ?
Great playground for stuff like this

And grouping matches so you can see subexpression matches helps a lot
From doing that this tells me, at least in RegExRX, that the initial .* matches the entire pattern and so the * is not “distinct”
Everything else shows as 0 width matches

A much simpler pattern seems to split things up and find the * though
^(.)(\)(.*)$

Bascially anything between the begining of the line and the * then any thing from the * to the end of the line

THAT SAID - why not just use “instr” and find the one * and grab everything before the * and every thing after the * as 2 chunks ?
A regex might be overkill

Thanks Norman,

I found another way:

[code]Dim result() As Text

result = myText.Split(" ")

For Each part As Text In result
If part.EndsWith("") Then Return part.ReplaceAll("")
Next[/code]

or split on the * ?

Assuming you only want to match words…

\\b(\\w+)\\*(?:\\s|$)

That’s not Unicode aware though.