Question: So I'm trying to find a string within a string, now I currently have this constructed in,

```
string str4;

var str5 = "   type: '");
foreach (string str6 in response.Split(new char[] { '\n' }))
{
    if (str6.StartsWith(str5))
    {
        str4 = str6.Replace(str5, "").Replace(" ", "").Replace("',", "");
        break;
    }
}

```

Which works as expected & will grab the text from 

```
type: '

```

Example of this is

```
type: ' EXAMPLE ',

```

Ouput after loop

```
EXAMPLE

```

Now the issue is that occasionally the spaces at the start of ' type: ' vary, so sometimes it may be equal to the spaces I provided, and other times it may not..

I was trying to use Regex so I could do something such as,

```
string str5 = "Regex(*)type: '"

```

Now of course that's completely incorrect in terms of usage, but my example shows the use of \* which would be equal to any possibilities, so therefore no matter on the number of spaces, I would still be able to extract the innertext from type.

Answer: 
You can use `.Trim()`, `.TrimStart()` and `.TrimEnd()`. Using Regex looks like extra overhead which you don't really need.
If this is just a simple extraction task with very limited variation in inputs, you *can* do it with plain Regex: 

```
var response = @"[{
   type: 'foo',
something: 'bar',
},
{
  type: 'baz',
  something: 'bat'
}]";
var types = Regex.Matches(response, @"\s*type\:\s*\'(.+)\'")
    .Cast<Match>()
    .Select(m => m.Groups.Cast<Group>().Skip(1).Single().Value);

```

But it *sounds like* you might be trying to write a parser for a programming or markup language. If so, I would highly recommend that you don't try to do that with Regex. Regular Expressions get really hairy the moment you start trying to handle things like escaped strings (`"type: 'I\'m a type: '"`).

If your input is in a standard format like JSON, use a parsing library for that format. If not, there are libraries like Sprache which make it easy to create powerful custom parsers.