0

I cannot manage to get a working regular expression (for use in ASP.NET Validataor) for the following criteria:

  • I want all chars from A-Z a-z 0-9
  • I don't want the Enter key

I have the expression: [\w\s,.-/]*[^\n] but that doesn't work.

Can anyone give me a hint?

3
  • 1
    Your regex example allows spaces, commas, dots, hyphens and slashes. Those doesn't belong to "all chars from A-Z a-z 0-9". You really, really, REALLY need to be more precise and descriptive. Commented May 27, 2010 at 12:42
  • By "I don't want the Enter key", do you mean "I want to match the parts of the string that don't contain \n" or "I don't want to find any matches if the string contains \n"? Commented May 27, 2010 at 12:47
  • some help : Regular expression basics Commented May 27, 2010 at 12:52

1 Answer 1

2

This will match only characters that you're requiring:

[A-Za-z0-9]+ 
Sign up to request clarification or add additional context in comments.

2 Comments

Hi... I forgot to told that i need the space char too. If i use your expression with the space [A-Za-z0-9\s]+ the enter is allowed too :(
@TiagoDias: \s is all white space characters, if you only want space " ", then include it directly [0-9 a-zA-Z]+.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.