Complex String Manipulation - Well Complex For Me Anyway
Author |
Message |
Code Kille #1 / 7
|
 Complex String Manipulation - Well Complex For Me Anyway
I need to be able to do the following to various strings that are presented to my application, they are all email addresses, and no it is not a mass emailer app. My app reads in the sender email address of messages that have been sent to me, I need to be able to strip and keep the first section of the email address, which is fine for most addresses but some have extra characters on them and I also need to strip these of. i.e Actual Email Address The Bit I Need
god
god
santa claus (no full stop)
also do this for the other addresses, but am not sure exactly how I should be scanning for these 'extra' characters. Just in case anybody is interested, i am writing this app to annouce new email messages using MS Agents, the output form my sound card is pumped into my house audio system, and works great at present but only for a few selected email addresses (those formatted like the first one). Any help much appreciated.
|
Fri, 02 Jul 2004 11:26:11 GMT |
|
 |
Terry Austi #2 / 7
|
 Complex String Manipulation - Well Complex For Me Anyway
Quote:
>I need to be able to do the following to various strings that are presented >to my application, they are all email addresses, and no it is not a mass >emailer app. >My app reads in the sender email address of messages that have been sent to >me, I need to be able to strip and keep the first section of the email >address, which is fine for most addresses but some have extra characters on >them and I also need to strip these of. >i.e >Actual Email Address The >Bit I Need
>god
>god
>santa claus (no full stop)
liberally: Address = Replace(Address, "<", "") Address = Replace(Address, ".", " ") --
http://www.hyperbooks.com/ Metacreator character software now available
|
Fri, 02 Jul 2004 13:56:16 GMT |
|
 |
Yaniv Sapi #3 / 7
|
 Complex String Manipulation - Well Complex For Me Anyway
Quote:
> I need to be able to do the following to various strings that are presented > to my application, they are all email addresses, and no it is not a mass > emailer app. > My app reads in the sender email address of messages that have been sent to > me, I need to be able to strip and keep the first section of the email > address, which is fine for most addresses but some have extra characters on > them and I also need to strip these of. > i.e > Actual Email Address The > Bit I Need
> god
> god
> santa claus (no full stop)
> also do this for the other addresses, but am not sure exactly how I should > be scanning for these 'extra' characters. > Just in case anybody is interested, i am writing this app to annouce new > email messages using MS Agents, the output form my sound card is pumped into > my house audio system, and works great at present but only for a few > selected email addresses (those formatted like the first one). > Any help much appreciated.
You can use the InStr() function to search for the extra characters in your splitted string. Then, if they exist, just truncate (or replace) them using the Left(), Right() or Mid() functions. Yaniv.
|
Fri, 02 Jul 2004 14:52:57 GMT |
|
 |
Tom Shelto #4 / 7
|
 Complex String Manipulation - Well Complex For Me Anyway
You can use Replace to remove any unwanted characters. Tom Shelton
Quote: > I need to be able to do the following to various strings that are presented > to my application, they are all email addresses, and no it is not a mass > emailer app. > My app reads in the sender email address of messages that have been sent to > me, I need to be able to strip and keep the first section of the email > address, which is fine for most addresses but some have extra characters on > them and I also need to strip these of. > i.e > Actual Email Address The > Bit I Need
> god
> god
> santa claus (no full stop)
can > also do this for the other addresses, but am not sure exactly how I should > be scanning for these 'extra' characters. > Just in case anybody is interested, i am writing this app to annouce new > email messages using MS Agents, the output form my sound card is pumped into > my house audio system, and works great at present but only for a few > selected email addresses (those formatted like the first one). > Any help much appreciated.
|
Fri, 02 Jul 2004 15:19:22 GMT |
|
 |
michael harringto #5 / 7
|
 Complex String Manipulation - Well Complex For Me Anyway
You could adapt it if you want to leave in upper case or numerics Option Explicit Private Sub Command1_Click() Dim myArray() As String Dim mystring As String Dim i As Integer
mystring = myArray(0) Print mystring ' Chr$(97)=a :Chr$(122)=z For i = 1 To 96 If InStr(mystring, Chr$(i)) > 0 Then mystring = Replace$(mystring, Chr$(i), " ") End If Next i For i = 123 To 255 If InStr(mystring, Chr$(i)) > 0 Then mystring = Replace$(mystring, Chr$(i), " ") End If Next i Print mystring End Sub
Quote: > I need to be able to do the following to various strings that are presented > to my application, they are all email addresses, and no it is not a mass > emailer app. > My app reads in the sender email address of messages that have been sent to > me, I need to be able to strip and keep the first section of the email > address, which is fine for most addresses but some have extra characters on > them and I also need to strip these of. > i.e > Actual Email Address The > Bit I Need
> god
> god
> santa claus (no full stop)
can > also do this for the other addresses, but am not sure exactly how I should > be scanning for these 'extra' characters. > Just in case anybody is interested, i am writing this app to annouce new > email messages using MS Agents, the output form my sound card is pumped into > my house audio system, and works great at present but only for a few > selected email addresses (those formatted like the first one). > Any help much appreciated.
|
Fri, 02 Jul 2004 20:41:05 GMT |
|
 |
Rick Rothstei #6 / 7
|
 Complex String Manipulation - Well Complex For Me Anyway
Give this a try...
For X = 1 To Len(NamePart) If Mid$(NamePart, X, 1) Like "[!a-zA-Z]" Then Mid$(NamePart, X) = " " End If Next Rick Quote:
> I need to be able to do the following to various strings that are presented > to my application, they are all email addresses, and no it is not a mass > emailer app. > My app reads in the sender email address of messages that have been sent to > me, I need to be able to strip and keep the first section of the email > address, which is fine for most addresses but some have extra characters on > them and I also need to strip these of. > i.e > Actual Email Address The > Bit I Need
> god
> god
> santa claus (no full stop)
> also do this for the other addresses, but am not sure exactly how I should > be scanning for these 'extra' characters. > Just in case anybody is interested, i am writing this app to annouce new > email messages using MS Agents, the output form my sound card is pumped into > my house audio system, and works great at present but only for a few > selected email addresses (those formatted like the first one). > Any help much appreciated.
|
Fri, 02 Jul 2004 21:01:24 GMT |
|
 |
Jason #7 / 7
|
 Complex String Manipulation - Well Complex For Me Anyway
Excellent, I will see what I can come up with form the ideas given to me here, again, thanks to all those that replied.
Quote: > I need to be able to do the following to various strings that are presented > to my application, they are all email addresses, and no it is not a mass > emailer app. > My app reads in the sender email address of messages that have been sent to > me, I need to be able to strip and keep the first section of the email > address, which is fine for most addresses but some have extra characters on > them and I also need to strip these of. > i.e > Actual Email Address The > Bit I Need
> god
> god
> santa claus (no full stop)
can > also do this for the other addresses, but am not sure exactly how I should > be scanning for these 'extra' characters. > Just in case anybody is interested, i am writing this app to annouce new > email messages using MS Agents, the output form my sound card is pumped into > my house audio system, and works great at present but only for a few > selected email addresses (those formatted like the first one). > Any help much appreciated.
|
Sat, 03 Jul 2004 04:54:49 GMT |
|
|
|