By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

string manipulation

P: 2
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
Share this Question
Share on Google+
3 Replies


P: 16
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
100+
P: 1,977
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
100+
P: 1,977
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.