Regex - Get all words that are not wrapped with a "/"

c#, regex, string

Solution

Just use this regular expression `\b(?<!/)\w+(?!/)\b`:

var str = "Hello Great /World/ /I/ am great too";
var words = Regex.Matches(str, @"\b(?<!/)\w+(?!/)\b")
    .Cast<Match>()
    .Select(m=>m.Value)
    .ToArray();

This will get you:

Hello
Great
am
great
too

Problem

Im really trying to learn regex so here it goes. I would really like to get all words in a string which do not have a "/" on either side. For example, I need to do this to: "Hello Great /World/" I need to have the results: "Hello" "Great" is this possible in regex, if so, how do I do it? I think i would like the results to be stored in a string array :) Thank you

Original source