Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:43:31+00:00 2026-06-02T08:43:31+00:00

I want to define a ‘valid’ input, which is _-. won’t be allowed in

  • 0

I want to define a ‘valid’ input, which is _-. won’t be allowed in the end or in the begining of the string, only allowed in the middle.

Acceptable characters (location doesn’t matter): a-zA-Z0-9 and all the hebrew letters which I don’t know how to allow them in a regex (maybe just hard-coding all the letters?)

Unacceptable characters (location doesn’t matter): All symbols, except the special ones I provided before.

I don’t know how to build this pattern, and if you can add tips and comments on every section so I will understand. Thanks!

This is not for homework, just for self learning.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:43:33+00:00Added an answer on June 2, 2026 at 8:43 am
    @"^[a-zA-Z\dא-ת][a-zA-Z_\-\.\dא-ת]*[a-zA-Z\dא-ת]$"
    

    If you want to allow “_.-” without duplicates:

    @"^[a-zA-Z\dא-ת]([a-zA-Z\dא-ת]+[_\.\-]?)*[a-zA-Z\dא-ת]$"
    

    If you want to allow white spaces in the middle:

    @"^[a-zA-Z\dא-ת][a-zA-Z_\-\.\d\sא-ת]*[a-zA-Z\dא-ת]$"
    

    If you want white spaces + “_.-” without duplicates:

    @"^[a-zA-Z\dא-ת]([a-zA-Z\d\sא-ת]+[_\.\-]?)*[a-zA-Z\dא-ת]$"
    

    So using the Regex:

    var isValid = Regex.IsMatch(input, @"...");
    

    Also, if you plan on using the regex many times in the code, I suggest adding RegexOptions.Compiled flag, to increase speed.

    var isValid = Regex.IsMatch(input, @"...", RegexOptions.Compiled);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to define the block as a string, then create the lambda. The
I want to define reader macros in such a way that they affect only
I want to define a std::map with key as std::pair<std::string, std::string> something like follow
I want to define a jsp tag, which can accept some extra attributes which
I want to define a long string and use it as a parameter in
I want to define an interface MyList which is a list of interface MyThing.
I want to define a class like this class HttpRestAccessor { public: IResource& UpdateResource(string&
I want to define a constant string containing non printable characters in C. For
I want to define a method on my application controller which I can then
I want to define a Python class that accepts different variables as input. However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.