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 8124551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:29:17+00:00 2026-06-06T06:29:17+00:00

Trying to figure out a regex for validating a network path ie: \\comp\xyz or

  • 0

Trying to figure out a regex for validating a network path ie: \\comp\xyz or \\comp or \\comp\x\y\z\storage or something much more lengthy on all parts but the jist of it is hopefully conveyed.

What I have currently is a simple input field, that I have a user passing information through. Thing of it is I don’t want them to put it in wrong as the backend connects to a client that uses it to run processes on computers across a network, so last thing I need is someone mistyping something and being the cause of something else breaking. So I figure a quick preg_match will do me just fine in confirming this from the PHP side I am currently work with but I do have a need to work this into JavaScript and a layer thats built on Ruby so I not knowing if all regex is equal or not I need one that works on all levels..

Also to save me time later in coming back I will eventually need to figure out a regex that will allow a user to do either local path ie: C:\, X:, H:\path\to\folder or a network path as mentioned prior.

  • 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-06T06:29:18+00:00Added an answer on June 6, 2026 at 6:29 am

    \\comp\x\y\z\storage:

    /^\\(\\[^\s\\]+)+(\\)?$/
    

    H:\path\to\folder:

    /^([A-Za-z]:(\\)?|[A-Za-z]:(\\[^\s\\]+)+)(\\)?$/
    

    Both:

    /^(\\(\\[^\s\\]+)+|([A-Za-z]:(\\)?|[A-z]:(\\[^\s\\]+)+))(\\)?$/
    

    Working demo: http://jsfiddle.net/DerekL/gLfdv/

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

Sidebar

Related Questions

I'm new to regex and trying to figure something out for use in scala.
Possible Duplicate: Regex question mark I am trying to figure out how to parse
I'm horrible with regex but i'm trying to figure out how an import function
Trying to figure out why my recipient multiselect isn't validating on form submission. Should
Ok Im trying to figure out this regex where I have a word, and
I am trying to figure out why a regex with negative look ahead fails
I been trying to figure out how this blasted regex for two hours!!! It's
I've been scratching my head trying to figure out how to use Regex.Replace to
Hi guys i am trying to figure out a simple regEx from the given
I'm fairly new to regex and trying to figure out a pattern that will

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.