|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Regular Expressions .NETcould help me out. I'm looking for the lines of code that will replace C: with nothing(""), AND all backslashes"\" to forward slashes"/". Example: ORGINAL x:\en\aviation\users.htm FINISHED PRODUCT /en/aviation/users.htm It would be awesome if I could hear from someone on this matter. Thanks! Justin You mean something like:
Dim str As String = "C:\en\aviation\users.htm" str = Regex.Replace(str, "C:", "") str = Regex.Replace(str, "\\", "/") MsgBox(str) Note, the following does the same thing: Dim str As String = "C:\en\aviation\users.htm" str.Replace("C:", "") str.Replace("\\", "/") MsgBox(str) Thanks, Seth Rowe Justin Fancy wrote: Show quoteHide quote > I am new to regular expressions with .net. I was wondering if someone > could help me out. > > I'm looking for the lines of code that will replace C: with > nothing(""), AND all backslashes"\" to forward slashes"/". > > Example: > > ORGINAL > > x:\en\aviation\users.htm > > FINISHED PRODUCT > > /en/aviation/users.htm > > It would be awesome if I could hear from someone on this matter. > > Thanks! > > Justin > Note, the following does the same thing: Oops, change "\\" to "\" Making it:> > Note, the following does the same thing: > > Dim str As String = "C:\en\aviation\users.htm" > str.Replace("C:", "") > str.Replace("\\", "/") > MsgBox(str) Dim str As String = "C:\en\aviation\users.htm" str.Replace("C:", "") str.Replace("\", "/") MsgBox(str) Using Regex.Replace requires using double backslashes as a backslash has special meaning to Regex. This cause str.Replace("\\", "/") to look for 2 backslashes instead of just one. Thanks, Seth Rowe rowe_newsgroups wrote: Show quoteHide quote > You mean something like: > > Dim str As String = "C:\en\aviation\users.htm" > str = Regex.Replace(str, "C:", "") > str = Regex.Replace(str, "\\", "/") > MsgBox(str) > > Note, the following does the same thing: > > Dim str As String = "C:\en\aviation\users.htm" > str.Replace("C:", "") > str.Replace("\\", "/") > MsgBox(str) > > Thanks, > > Seth Rowe > > > Justin Fancy wrote: > > I am new to regular expressions with .net. I was wondering if someone > > could help me out. > > > > I'm looking for the lines of code that will replace C: with > > nothing(""), AND all backslashes"\" to forward slashes"/". > > > > Example: > > > > ORGINAL > > > > x:\en\aviation\users.htm > > > > FINISHED PRODUCT > > > > /en/aviation/users.htm > > > > It would be awesome if I could hear from someone on this matter. > > > > Thanks! > > > > Justin Seth,
Try: > Dim str As String = "C:\en\aviation\users.htm" str = str.Replace("C:", "")str = str.Replace("\", "/") > MsgBox(str) As String.Replace is a function that returns the modifed string.-- Show quoteHide quoteHope this helps Jay B. Harlow ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "rowe_newsgroups" <rowe_em***@yahoo.com> wrote in message news:1161701975.078650.193980@f16g2000cwb.googlegroups.com... >> Note, the following does the same thing: >> >> Note, the following does the same thing: >> >> Dim str As String = "C:\en\aviation\users.htm" >> str.Replace("C:", "") >> str.Replace("\\", "/") >> MsgBox(str) > > Oops, change "\\" to "\" Making it: > > Dim str As String = "C:\en\aviation\users.htm" > str.Replace("C:", "") > str.Replace("\", "/") > MsgBox(str) > > Using Regex.Replace requires using double backslashes as a backslash > has special meaning to Regex. This cause str.Replace("\\", "/") to look > for 2 backslashes instead of just one. > > Thanks, > > Seth Rowe > > > rowe_newsgroups wrote: >> You mean something like: >> >> Dim str As String = "C:\en\aviation\users.htm" >> str = Regex.Replace(str, "C:", "") >> str = Regex.Replace(str, "\\", "/") >> MsgBox(str) >> >> Note, the following does the same thing: >> >> Dim str As String = "C:\en\aviation\users.htm" >> str.Replace("C:", "") >> str.Replace("\\", "/") >> MsgBox(str) >> >> Thanks, >> >> Seth Rowe >> >> >> Justin Fancy wrote: >> > I am new to regular expressions with .net. I was wondering if someone >> > could help me out. >> > >> > I'm looking for the lines of code that will replace C: with >> > nothing(""), AND all backslashes"\" to forward slashes"/". >> > >> > Example: >> > >> > ORGINAL >> > >> > x:\en\aviation\users.htm >> > >> > FINISHED PRODUCT >> > >> > /en/aviation/users.htm >> > >> > It would be awesome if I could hear from someone on this matter. >> > >> > Thanks! >> > >> > Justin > Thanks for the correction Jay!
Perhaps I should type my responses in the ide before posting them....... :-) Thanks,Seth Rowe Jay B. Harlow wrote: Show quoteHide quote > Seth, > Try: > > > Dim str As String = "C:\en\aviation\users.htm" > str = str.Replace("C:", "") > str = str.Replace("\", "/") > > MsgBox(str) > > As String.Replace is a function that returns the modifed string. > > -- > Hope this helps > Jay B. Harlow > .NET Application Architect, Enthusiast, & Evangelist > T.S. Bradley - http://www.tsbradley.net > > > "rowe_newsgroups" <rowe_em***@yahoo.com> wrote in message > news:1161701975.078650.193980@f16g2000cwb.googlegroups.com... > >> Note, the following does the same thing: > >> > >> Note, the following does the same thing: > >> > >> Dim str As String = "C:\en\aviation\users.htm" > >> str.Replace("C:", "") > >> str.Replace("\\", "/") > >> MsgBox(str) > > > > Oops, change "\\" to "\" Making it: > > > > Dim str As String = "C:\en\aviation\users.htm" > > str.Replace("C:", "") > > str.Replace("\", "/") > > MsgBox(str) > > > > Using Regex.Replace requires using double backslashes as a backslash > > has special meaning to Regex. This cause str.Replace("\\", "/") to look > > for 2 backslashes instead of just one. > > > > Thanks, > > > > Seth Rowe > > > > > > rowe_newsgroups wrote: > >> You mean something like: > >> > >> Dim str As String = "C:\en\aviation\users.htm" > >> str = Regex.Replace(str, "C:", "") > >> str = Regex.Replace(str, "\\", "/") > >> MsgBox(str) > >> > >> Note, the following does the same thing: > >> > >> Dim str As String = "C:\en\aviation\users.htm" > >> str.Replace("C:", "") > >> str.Replace("\\", "/") > >> MsgBox(str) > >> > >> Thanks, > >> > >> Seth Rowe > >> > >> > >> Justin Fancy wrote: > >> > I am new to regular expressions with .net. I was wondering if someone > >> > could help me out. > >> > > >> > I'm looking for the lines of code that will replace C: with > >> > nothing(""), AND all backslashes"\" to forward slashes"/". > >> > > >> > Example: > >> > > >> > ORGINAL > >> > > >> > x:\en\aviation\users.htm > >> > > >> > FINISHED PRODUCT > >> > > >> > /en/aviation/users.htm > >> > > >> > It would be awesome if I could hear from someone on this matter. > >> > > >> > Thanks! > >> > > >> > Justin > > Justin Fancy wrote:
Show quoteHide quote > I am new to regular expressions with .net. I was wondering if someone Removing the drive letter can be done with a regular expression:> could help me out. > > I'm looking for the lines of code that will replace C: with > nothing(""), AND all backslashes"\" to forward slashes"/". > > Example: > > ORGINAL > > x:\en\aviation\users.htm > > FINISHED PRODUCT > > /en/aviation/users.htm > > It would be awesome if I could hear from someone on this matter. > > Thanks! > > Justin > path = Regex.Replace(path, "^[A-Z]:", "") Replacing the backslashes can be done with just a regular replace. Thanks a million people!!
J Göran Andersson wrote: Show quoteHide quote > Justin Fancy wrote: > > I am new to regular expressions with .net. I was wondering if someone > > could help me out. > > > > I'm looking for the lines of code that will replace C: with > > nothing(""), AND all backslashes"\" to forward slashes"/". > > > > Example: > > > > ORGINAL > > > > x:\en\aviation\users.htm > > > > FINISHED PRODUCT > > > > /en/aviation/users.htm > > > > It would be awesome if I could hear from someone on this matter. > > > > Thanks! > > > > Justin > > > > Removing the drive letter can be done with a regular expression: > > path = Regex.Replace(path, "^[A-Z]:", "") > > Replacing the backslashes can be done with just a regular replace.
Calculate height in millimeters of a font
Issue with VB6 using a .NET DLL on one PC with Windows 2000 Server how to round number to custom step (0.25, 20, 100...) Remoting Bug in Radio Button (or weird feature) system.enum.getvalues Compilation in dot NET Quick SQLclient Data Access ASPX / VB .NET Sum of a DataGridView column Shared Compression for VB.NET and PHP |
|||||||||||||||||||||||