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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:36:17+00:00 2026-05-21T21:36:17+00:00

I’ve had some serious issues with trying to get my Regex working properly trying

  • 0

I’ve had some serious issues with trying to get my Regex working properly trying to extract an UNC path. I’ve read through countless tutorials, guides and even tested my regex’s in online regexp testers (where they seem to work), but I still can’t get it to work in my code. I can, however, get it working in PHP for example.

I’m using PrimalScript to try to see what goes wrong, more on that later. Here’s my current code which I’m using:

Dim WSHShell, strString, nrMatches, myMatches

Set WSHShell = CreateObject("WScript.Shell")
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
' myRegExp.Pattern = "^\\\\(.*?)+\\(.*)*\s...\\(.*)*$"  <-- Returns 1 match, the whole String
' myRegExp.Pattern = "^\\\\(\w?)+\\(\w)*\s...\\(\w)*$"  <-- Returns 0 matches
' myRegExp.Pattern = "^\\\\(.*?)+\\\(.*)*\s...\\\(.*)*$"  <-- Gives Syntax Error
' myRegExp.Pattern = "^\\\\\\\\(.*?)+\\\(.*)*\s...\\\(.*)*$" <-- Gives Syntax Error
' myRegExp.Pattern = "^\\\\(.*)\\(.*)\s\.\.\.\\(.*)?$"  <-- Returns 1 match, the whole String
myRegExp.Pattern = "^(.*)+\\(.*)+(\s\.\.\.\\(.*))?$" ' <-- Returns 1 match, the whole String

strString = "\\domain.subnet.net\share1 ...\share2"

Set myMatches = myRegExp.Execute(strString)
nrMatches = myMatches.Count
MsgBox "Found " & nrMatches & " Matches!", vbOKOnly, "Number of Matches"
For Each myMatch In myMatches
    MsgBox "Value: " & myMatch.Value, vbOKOnly, "Found Match"
Next
WScript.Quit

The commented regex’s are just a small portion of what I’ve tried, these are the ones I’ve had “most” sucess with.

One thing that caught my eye was that, while debugging in PrimalScript, it basically told me that the myMatches.Item = Invalid number of parameters
Googling on it gave me nothing, though, but perhaps someone here knows what parameters Execute needs?
I could provide a screenshot of it if necessary, just let me know.

Thanks, I’ll appreciate any pointers or tips to help me get this going =]

  • 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-05-21T21:36:18+00:00Added an answer on May 21, 2026 at 9:36 pm

    I am not sure what you are expecting.

    Do you want to result strString = "\\domain.subnet.net\share1 ...\share2" in 2 matches? (Would …\share2 be a valid path?)

    If there are only paths in your string divided by whitespace, then you can try:

    [^\s]+ see rubular

    or

    [\\\w.]+ see rubular

    or if it has to start with \\or .

    (?<=\A|\s)(?:\\|\.)[^\s]+ see Regexr (because rubular does not support look behinds)

    UPDATE:

    According to your comments, I hope this will do what you want:

    ^((?:\\|\.)[^\s]+)\\[^\\\s]+\s+\.{3}([^\s]*)
    

    Rubular

    You will find the path till the last \ in the group 1 and the part following on the ... in group 2. So to get your replacement you have just to concatenate group 1 and group 2.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.