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

  • SEARCH
  • Home
  • 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 9093381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:05:10+00:00 2026-06-16T23:05:10+00:00

Problem Statement: I’m trying to build a regular expression which accepts two consecutive special

  • 0

Problem Statement:

I’m trying to build a regular expression which accepts two consecutive special characters like: /_ or \\ or ./ or -- or \- or any other combination of special charcters (./\_-),in the regular expression mentioned below:

^[a-zA-Z0-9\d]{1}[a-zA-Z0-9\d._/\-]{0,49}$

What i’m doing wrong here?

  • 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-16T23:05:12+00:00Added an answer on June 16, 2026 at 11:05 pm

    mlorbetske’s regex can be rewritten a bit to remove the use of conditional regex. I also remove the redundant 0-9 from the regex, since it has been covered by \d.

    ^[a-zA-Z\d](?:[a-zA-Z\d]|(?<![._/\\\-])[._/\\\-]){0,49}$
    

    The portion (?:[a-zA-Z\d]|(?<![._/\\\-])[._/\\\-]) matches alphanumeric character, OR special character ., _, /, \, - if the character preceding it is not a special character already. I also make the group non-capturing (?:pattern), since it seems that the regex is used for validation only.

    I made use of the zero-width negative look-behind assertion (?<!pattern) to assert the character in front is not one of the special characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem statement which is working but still i would like to
I started learning regular expression recently. I have a small problem statement now. I
Problem statement: It is necessary for me to write a code, whether which before
Problem statement I'm trying to implement my own virtual keyboard following example softkeyboard, found
Problem Statement - Would like to know if particular web app user is active
Problem statement:- I want to create 50 instances of a vector(1 Dimension) which contains
Sorry for the long problem statement...I've spent two days debugging and have a lot
Problem Statement: I would like to create an offline database to lookup prices/info on
What are the steps that you follow when approaching a problem statement, which needs
Problem Statement: Currently, there are two requirements namely having the correctly populated element in

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.