CSharp examples for System:String Contain
Whether a string is a compound word, ie if it contains a '-' inside the word. Ex: -test -> not compound six-figure -> compound
using System.Threading.Tasks; using System.Text.RegularExpressions; using System.Text; using System.Net.Mail; using System.Linq; using System.Globalization; using System.Collections.Generic; using System;//from www. j a v a2 s.c o m public class Main{ /// <summary> /// Whether a string is a compound word, ie if it contains a '-' inside the word. /// Ex: /// -test -> not compound /// six-figure -> compound /// </summary> public static bool IsCompoundWord(string input) { if (string.IsNullOrEmpty(input)) { return false; } return Regex.IsMatch(input, "^(\\w+\\-)+\\w+$"); } }