extract UNC path using regular expression

  • Thread starter Thread starter ksr
  • Start date Start date
K

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
 
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.
 
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
 
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).
 
Back
Top