hi,
how can i check for a word that has noncharaters in it,
as like sdf4df, 4rtrt, 909erter,

appreciate a reply,
thanks

Recommended Answers

Give it a try.

Hint: Use a for-loop.

Jump to Post

When you use regular expressions, you must specify where it occurs in the string. To specify the whole string, you use \A at the beginning and \z at the end of the expression (case-sensitive). I had no idea [:lower:] would work in C#, however you can also …

Jump to Post

All 8 Replies

Give it a try.

Hint: Use a for-loop.

i used

if (Regex.IsMatch(s.ToLower(), "[:lower:]"))
                                {}



                            it dosen't get rid of werwer343 words

When you use regular expressions, you must specify where it occurs in the string. To specify the whole string, you use \A at the beginning and \z at the end of the expression (case-sensitive). I had no idea [:lower:] would work in C#, however you can also use \w+ which matches any word character; then you wouln't have to use ToLower(). Note that regex character escapes are different than C# character escapes. For instance, you would either use:

"\\A\\w+\\z"

or

@"\A\w+\z"

since @ tells the compiler to ignore character escape sequences. See Regular Expression Language - Quick Reference for more info.

so \A is the beginning and the \z is match at the end. where do i specify that I want only to match alphabatical letter, because w+ is for 'any word charter' which includes number also
how do i specify from a-z from the beginning to the end and in the middle?

Oh yeah, it is...

You could either use [a-zA-Z], or [a-z] with RegexOptions.IgnoreCase.

can someone help me in this

so when i use @"\A[a-z] \z[a-z] it dosen't work

Did you read the link I gave you? You still need the +, as that means one or more, and nothing should come after the \z. Also, you can't have any spaces in there, since that's a literal.

got it, the answer

@"\A[a-z]+\z"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.