I am in troubles with how to use C#’s Regex to extract specific words from the below.
I am %NAME% from the US. Hobby : %HOBBY% Job : Software Engineer With you, %YOUR_NAME%, let's discuss about C#
*This sentence is assigned to one variable (e.g. strText)
This is a problem I am facing:
I want to extract words, which have “%” at the start and end of them from this strText.
(i.e. I want to assign %NAME%, %HOBBY%, %YOUR_NAME% to valuables.)
I came up with an idea of “Regex.Matches(strText, “b%.+%b”) “, but this expression does not work as I expect.
So, I would be very grateful to you if you could kindly show me right expressions to get these %—% words from the sentense. Any idea is welcomed.
I learned that “Regex.Matches()” would go as I expected, according to https://www.sejuku.net/blog/54508#index_id4
But I realized that I had to modify this expression when it did not go well.