Use \S
(which is negation of \s
= non-whitespace character):
@"^\S+$"
If empty string is allowed, replace +
with *
:
@"^\S*$"
More Related Contents:
- How to write a regular expression in c# to match internal links to articles in Wikipedia? [duplicate]
- Extract title from name in c# [closed]
- How to cut up a string from an input file with Regex or String Split, C#?
- How to Parse using Regex in C# [closed]
- C# regex replace of numbers and units
- How do I extract text that lies between parentheses (round brackets)?
- How do I replace the *first instance* of a string in .NET?
- Escape Special Character in Regex
- Replace first occurrence of pattern in a string [duplicate]
- Regex to strip line comments from C#
- split a comma-separated string with both quoted and unquoted strings [duplicate]
- C#, regular expressions : how to parse comma-separated values, where some values might be quoted strings themselves containing commas
- Matching strings with wildcard
- C# Regex for Guid
- C# Regex Split – everything inside square brackets
- Check for special characters (/*-+_@&$#%) in a string?
- return only Digits 0-9 from a String
- Count regex replaces (C#)
- Standalone numbers Regex?
- Regex replace multiple groups
- Regex: match word that ends with “Id”
- C# Regex: Checking for “a-z” and “A-Z”
- Regular expression for URL
- Convert JavaScript Regex to C#
- C# System.RegEx matches LF when it should not
- Regex for matching a character, but not when it’s enclosed in square bracket
- Regular expression to split string and number
- regex to find a word before and after a specific word
- Regular expression for version numbers
- regular expression for anything but an empty string