Domanda

I want to be able to do a string search for the following:

[DOUBLE_QUOTE] [ANY_COMBINATION_OF_SPACES_AND_TABS] [COMMA] [ANY_COMBINATION_OF_SPACES_AND_TABS] [DOUBLE_QUOTE]

The tricky part for me is identifying the [ANY_COMBINATION_OF_SPACES_AND_TABS]. How can I accomplish this using a regex in C#?

Nessuna soluzione corretta

Altri suggerimenti

[ \t]

Would match a space or a tab. To match any number of these (including 0) you could use the * quantifier:

[ \t]*

Use the + quantifier if you mean 1 or more, eg: [ \t]+

If you mean any whitespace you could use \s instead of [ \t].

In regex \s covers any kind of white spaces including tabs(\t). So you can easily use \s for this.

But if you want to ignore the others and only strict to space and tab, then you can use this one as well.

[ \t]+

On the whole, it could probably be one of these

"[ \t]*,[ \t]*"
or
"\h*,\h*"

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top