469,645 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

string manipulation

String Manipulation: Given a string like “This is a string”, I want to remove all single characters( alphabets and numerals) like (a, b, 1, 2, .. ) .

So the output of the string will be “This is string”

This is very urgent. Please help
Feb 7 '07 #1
3 1377
String Manipulation: Given a string like “This is a string”, I want to remove all single characters( alphabets and numerals) like (a, b, 1, 2, .. ) .

So the output of the string will be “This is string”

This is very urgent. Please help

Can you implement the following logic:

if the string starts with a single character followed by a blank space OR
if the string ends with a blank space followed by a single character OR
any occurences of a substring of three characters where the first and last character of the substring are blank spaces THEN replace it by an empty substring.

Hope it helps.
Feb 8 '07 #2
hariharanmca
1,977 1GB
String Manipulation: Given a string like “This is a string”, I want to remove all single characters( alphabets and numerals) like (a, b, 1, 2, .. ) .

So the output of the string will be “This is string”

This is very urgent. Please help
Private Function ValidateSingleCharacter(pStrValue As String) As String
Dim strTmpArray() As String
Dim NoValue As Long, i As Integer
NoValue = UBound(Split(Trim(pStrValue), " "))
ReDim strTmpArray(NoValue) As String
strTmpArray = Split(Trim(pStrValue), " ")
For i = 0 To NoValue
If Len(strTmpArray(i)) = 1 Then strTmpArray(i) = "" else: strTmpArray(i) = strTmpArray(i) & " "
Next i
ValidateSingleCharacter = Join(strTmpArray, "")
End Function

I think this will help you
Feb 8 '07 #3
hariharanmca
1,977 1GB
Private Function ValidateSingleCharacter(pStrValue As String) As String
Dim strTmpArray() As String
Dim NoValue As Long, i As Integer
NoValue = UBound(Split(Trim(pStrValue), " "))
ReDim strTmpArray(NoValue) As String
strTmpArray = Split(Trim(pStrValue), " ")
For i = 0 To NoValue
If Len(strTmpArray(i)) = 1 Then strTmpArray(i) = "" else: strTmpArray(i) = strTmpArray(i) & " "
Next i
ValidateSingleCharacter = Join(strTmpArray, "")
End Function

I think this will help you
Beter use

ValidateSingleCharacter = trim(Join(strTmpArray, ""))
Feb 8 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

32 posts views Thread by tshad | last post: by
29 posts views Thread by zoro | last post: by
4 posts views Thread by WaterWalk | last post: by
10 posts views Thread by micklee74 | last post: by
3 posts views Thread by frankeljw | last post: by
22 posts views Thread by mann_mathann | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.