473,763 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extract UNC path using regular expression

ksr
Hi,
I am looking for a regular expression that would extract UNC paths from a
given string and place that inside a href.
Currently the expression fails if there is a space in the path..

eg. \\server\my doc.doc

is there a regular expression to do this?

TIA,
ks
Nov 18 '05 #1
3 6033
"ksr" <k_*******@nosp am.hotmail.com> wrote in news:OV94Tn0cEH A.556
@tk2msftngp13.p hx.gbl:
I am looking for a regular expression that would extract UNC paths from a
given string and place that inside a href.
Currently the expression fails if there is a space in the path..
eg. \\server\my doc.doc
is there a regular expression to do this?


Regexps are not magic. If you have a string like "Jake, read the docs in
\\server1\code documentation\c oolproject for windows and its
subdirectories" , it's impossible to make a reasonable guess on where the
UNC path might end.

So, if you can come up with the logic first, then you can ask for a regexp
representation.
--
Jouni Heikniemi, jo********@heik niemi.net
http://www.heikniemi.net/hc/ (blog)
Nov 18 '05 #2
ksr
Thnaks for the reply. This is what the requirement is.. There is a multiline
textbox and users can enter some text and UNC path. If there is space
between the words inside path then the path will be enclosed in <path goes
here> . I am new to regular expressions and looking for some help in this
regard.

Hope this clears the logic part of it. Please help me with this

Appreciate your help

TIA

"Jouni Heikniemi" <jo********@hei kniemi.net> wrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"ksr" <k_*******@nosp am.hotmail.com> wrote in news:OV94Tn0cEH A.556
@tk2msftngp13.p hx.gbl:
I am looking for a regular expression that would extract UNC paths from a given string and place that inside a href.
Currently the expression fails if there is a space in the path..
eg. \\server\my doc.doc
is there a regular expression to do this?


Regexps are not magic. If you have a string like "Jake, read the docs in
\\server1\code documentation\c oolproject for windows and its
subdirectories" , it's impossible to make a reasonable guess on where the
UNC path might end.

So, if you can come up with the logic first, then you can ask for a regexp
representation.
--
Jouni Heikniemi, jo********@heik niemi.net
http://www.heikniemi.net/hc/ (blog)

Nov 18 '05 #3
"ksr" <k_*******@nosp am.hotmail.com> wrote in
news:uY******** ******@TK2MSFTN GP12.phx.gbl:
in <path goes here> . I am new to regular expressions and looking for
some help in this regard.
Hope this clears the logic part of it. Please help me with this


Read a tutorial, it'll help you in the future.
<http://www.regular-expressions.inf o> is a decent one.

Try this for a regexp: (?:<(\\\\[-\d\w\\\s]+?)>)|(\\\\[-\d\w\\]+)

It should capture the UNCs you want. Note that if you put it into a C#
string, you need to double all backspaces (yes, there are quite a few of
them then).
--
Jouni Heikniemi, jo********@heik niemi.net
http://www.heikniemi.net/hc/ (blog)
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10147
by: Jay Douglas | last post by:
Hello all. I'm having a hard time coming up with a regular expression that can extract just the numbers out of string into a GroupCollection. Any help is appreciated.
3
5058
by: jarod1701 | last post by:
Hi, I'm currently trying to create a regular expression that can extract certain elements from a url. The url will be of the following form: http://user:pass@www.sitename.com I want a regex that matches the "user" part of that url.
7
2896
by: teo | last post by:
hallo, I need to extract a word and few text that precedes and follows it (about 30 + 30 chars) from a long textual document. Like the description that Google returns when it has found a given word. In example from:
9
7308
by: trihanhcie | last post by:
Hi, I would like to extract the text in an HTML file For the moment, I'm trying to get all text between <tdand </td>. I used a regular expression because i don't know the "format between <tdand </td> It can be : <tdtext1 </td> or
6
5957
by: Dave | last post by:
Hope someone can help! I have a memo fiels in which there are a few numbers including dates but what I want to do is extract a number which is 6 figures long. Can anyone help me? Thanks Dave
1
2270
by: maverickx | last post by:
Hi everyone, this is about my one project, i was planning to do like this: Firstly i printed out the source code of one html page on the DOS window, and then use PERL Regular Expression to extract specifc data from the source code , at last save these data in MYSQL tables. Does this work?
20
14664
by: kosanovic | last post by:
Hello, I'm bad at regular expressions. Would somebody help me: I need to extract all URL to .jpg and .png pictures from a string containing an HTML file (DOM wouldn't work well in what I need). I've tried: preg_match_all("/.jpg$|.png$/", $htmlfile, $Matches); foreach ($Matches as $match) {
3
2473
by: suzanne.boyle | last post by:
Hi I have an html file with headings followed by one or more paragraphs like this <h2>blah blah 1</h2> <p>more blah blah blah</p> <h2>blah blah 2</h2> <p>more blah blah blah</p>
3
4104
rizwan6feb
by: rizwan6feb | last post by:
I am trying to extract php code from a php file (php file also contains html, css and javascript code). I am using the following regex for this <\?*?\?> but this doesn't cater quotation marks (single and double quotes) and comments, i mean how can i skip php tags inside a string (and comments). Please have a look at the following code <?php include("db.php"); $name=$_REQUEST;
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10145
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9998
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.