Member_2_1242703
asked on
help with a string
fullName = result.Properties("display Name")(0)
How would I say...
if fullName includes a [ then chop off everything to the right of [
How would I say...
if fullName includes a [ then chop off everything to the right of [
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It should work this way as well
Dim fullName() As String
fullName = result.Properties("display Name")(0). Split("["c )
Dim fullName() As String
fullName = result.Properties("display
ASKER
Cast from type 'String()' to type 'String' is not valid.
on all of them
on all of them
ASKER
nevermind...i see what i did
ASKER
is there a way to split everything after a space and then [
if the string was LastName, FirstName [whatever]
then i would want my value to be
LastName, FirstName
i tried
fullName = result.Properties("display Name")(0). Split(" ", "["c)
but it returns
LastName,
if the string was LastName, FirstName [whatever]
then i would want my value to be
LastName, FirstName
i tried
fullName = result.Properties("display
but it returns
LastName,
fullName = result.Properties("display Name")(0). Split(" [")
ASKER
tried that and got...
Character constant must contain exactly one character.
Character constant must contain exactly one character.
Alright then... I'll stand by my original suggestion:
If fullName.IndexOf("[")>0 then
fullName = fullName.Substring(fullnam e.indexof( " ["))
end if
If fullName.IndexOf("[")>0 then
fullName = fullName.Substring(fullnam
end if
oops
If fullName.IndexOf(" [")>0 then
fullName = fullName.Substring(fullnam e.indexof( " ["))
end if
If fullName.IndexOf(" [")>0 then
fullName = fullName.Substring(fullnam
end if
ASKER
wouldn't that return everything to the right of the [
[whatever]
instead of
LastName, FirstName
??
[whatever]
instead of
LastName, FirstName
??
sorry... forgot it was start,length... not just length...
If fullName.IndexOf(" [")>0 then
fullName = fullName.Substring(0,fulln ame.indexo f(" ["))
end if
If fullName.IndexOf(" [")>0 then
fullName = fullName.Substring(0,fulln
end if
Sorry I was away from my desk.
Dim SplitName() As String
SplitName = fullName.Split(" "c)
Dim SplitName() As String
SplitName = fullName.Split(" "c)
Sorry I was away from my desk.
Imports System.Text.RegularExpress ions
Dim SplitName() As String
SplitName = fullName.Split(" "c)
SplitName(0) has the first part of the name just before the space
SplitName(1) Has everything after the space
I am using Regular Expressions to remove the { } if any
Dim m As Match = Regex.Match(SplitName(1), "\[(?<LName>.*)\]|(?<LName >.*)")
SplitName(1) = m.Groups("LName").Value
Sorry about the delay, fires to put out
Imports System.Text.RegularExpress
Dim SplitName() As String
SplitName = fullName.Split(" "c)
SplitName(0) has the first part of the name just before the space
SplitName(1) Has everything after the space
I am using Regular Expressions to remove the { } if any
Dim m As Match = Regex.Match(SplitName(1), "\[(?<LName>.*)\]|(?<LName
SplitName(1) = m.Groups("LName").Value
Sorry about the delay, fires to put out
ASKER
Thanks guys...it's all working great now! :-)
fullName = fullName.Substring(fullnam
end if