|
-
Dec 20th, 2003, 11:53 AM
#1
Thread Starter
Frenzied Member
Conditional Search and Replace?
I'd like to search a string for x0A and replace it with x0D0A, but only if x0A is not directly following x0D.
Reason is, I'm receiving bytes through a socket and displaying the results in a text box.
I thought this might be a good opportunity to use regular expressions, but not sure what the character sequence should be. Should I study regex more for this task or is there a better way to do it?
TIA,
Mike
-
Dec 20th, 2003, 12:14 PM
#2
Sleep mode
IndexOf can do this. It return the index of the string being searched . Returns -1 if no matches . Search the forum for previous posts about IndexOf method .
-
Dec 20th, 2003, 12:38 PM
#3
Thread Starter
Frenzied Member
IndexOf I understand, but I don't get how I would use in this context. Maybe I wasn't clear in my original post.
I can receive any number of bytes over the socket, sometimes several thousand (in 1024 blocks). In this response, there are many x0A characters, which I would like to replace with x0D0A. However, there are also already x0D0A sequences also, so I don't want those to end up being X0D0D0A.
Right now I'm searching for x0D0A, replacing with x0A, then search for x0A and replacing with x0D0A. This method just doesn't seem effecient.
-
Dec 20th, 2003, 12:47 PM
#4
Sleep mode
Are you doing something like this ?
VB Code:
Dim s As String = "Firstx0D0ASecondx0D0AThirdx0D0A"
MessageBox.Show(s.Replace("x0D0A", "x0A"))
forget about IndexOf now .
-
Dec 20th, 2003, 01:15 PM
#5
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|