By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,658 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,658 IT Pros & Developers. It's quick & easy.

extract UNC path using regular expression

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
"ksr" <k_*******@nospam.hotmail.com> wrote in news:OV94Tn0cEHA.556
@tk2msftngp13.phx.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\coolproject 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********@heikniemi.net
http://www.heikniemi.net/hc/ (blog)
Nov 18 '05 #2

P: n/a
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********@heikniemi.net> wrote in message
news:Xn**********************************@127.0.0. 1...
"ksr" <k_*******@nospam.hotmail.com> wrote in news:OV94Tn0cEHA.556
@tk2msftngp13.phx.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\coolproject 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********@heikniemi.net
http://www.heikniemi.net/hc/ (blog)

Nov 18 '05 #3

P: n/a
"ksr" <k_*******@nospam.hotmail.com> wrote in
news:uY**************@TK2MSFTNGP12.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.info> 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********@heikniemi.net
http://www.heikniemi.net/hc/ (blog)
Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.