c# - Alphanumeric not working with underscore -


I am using the following REGEX and what I need, only accept the following uncounted alphanumeric values ​​

  1. should not start with the number 2. Accept the underscores between the character 3. The value may be after the value   

For example

aa_bb a1_a2

I tried with the following which is not working well:

  @ "^ [a-zA-Z0 - 9] + (_ [A-zA-Z0- 9] +] * $ ",    

  @ "^ [A-zA-Z] [a-zA-Z0- 9 _.] + \ S? $"   

Use this regex. < P> There are many flaws in your regex

  • ^ [a-zA-Z0- 9] + will allow numbers to begin the test string.
  • There is no space in the end so it will not allow space.

    Demo here:

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -