List Info

Thread: How to replace all occurences of character within a section of string.




How to replace all occurences of character within a section of string.
user name
2006-03-10 21:30:09
Thanks.. I will look into that.. I did figure out a not so
pretty way of
doing it. Oh well. I guess it does work...

    Private Function FixSlashInPath(ByVal thisfile As
String) As String
        Dim iLoop As Integer
        Dim tempString As String
        Dim newString As String
        For iLoop = 0 To thisfile.Length - 5
            If thisfile.Substring(iLoop, 3) =
"src" Then
                tempString = thisfile.Substring(iLoop + 5,
thisfile.IndexOf(Chr(34), iLoop + 6) - (iLoop + 5))
                newString =
tempString.Replace("\", "/")
                thisfile = thisfile.Replace(tempString,
newString)
            End If
        Next
        Return thisfile
    End Function


Thanks.
 
Stacey
-----Original Message-----
From: Discussion of writing applications and components
using Visual
Basic .NET [mailto:VBDOTNETDISCUSS.DEVELOP.COM] On
Behalf Of Pardee,
Roy
Sent: Friday, March 10, 2006 3:56 PM
To: VBDOTNETDISCUSS.DEVELOP.COM
Subject: Re: [VBDOTNET] How to replace all occurences of
character
within a section of string.

I bet you want System.Text.REgularExpressions.  Bit of a
learning curve
there, but it *so* rewards study...

HTH,

-Roy

-----Original Message-----
From: Discussion of writing applications and components
using Visual
Basic .NET [mailto:VBDOTNETDISCUSS.DEVELOP.COM] On
Behalf Of Stacey
Levine
Sent: Friday, March 10, 2006 12:59 PM
To: VBDOTNETDISCUSS.DEVELOP.COM
Subject: [VBDOTNET] How to replace all occurences of
character within a
section of string.


I know that the string object has the .replace which will
replace all
occurrences of a selected text with the result. My problem
is a little
different. Part of a string is as below. Unfortunately, the
entire
document can't be treated as an XML document. What I need
to do is
locate all of the strings indicated by src=  and replace all
of the
backslashes with forward slashes. I could get firstIndex of
src.. but
what I really want is all indexes of src and then I could
scan for " and
then " and work on the area in the middle.  My head is
spinning a little
right now. Looking for any suggestions.. thanks.

 

.....10.0.0.3990"/><title>Playlist</title&
gt;</head><body><seq><media
src="\\vmcstream\C\wmpub\WMRoot\39398\39398_D1_
2.wma"/><media
src="\\vmcstream\C\wmpub\WMRoot\39398\39398_D1_
3.wma"/><media
src="\\vmcstream\C\wmpub\WMRoot\39398\39398_D1_
4.wma"/><media
src="\\vmcstream\C\wmpub\WMRoot\39398\39398_D1_
5.wma"/><media
src="\\vmcstream\C\wmpub\WMRoot\39398\39398_D1_
6.wma"/>

 

Stacey Levine

Lead Technical Architect

Value Music Concepts

825-C Franklin Court

Marietta, GA 30067

678-229-4255

 


===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )