Extracting string

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a string with two $ sign in between, like ab$cdefg$eurur. I need to
extract the right most part of the string from just right of the $ sign. How
do I do this?

Thanks

Regards
 
Try this:

Dim str As String = "ab$cdefg$eurur"
str = str.Substring(0, str.IndexOf("$", 0))
 
You may use the Split Method that will split the string based on the
character passed (in this case $)
It returns an array of string and you may choose the string that you like
(The string to the right of the right $ will have index 2 of the array)

hth,
Samuel Shulman
 
John said:
I have a string with two $ sign in between, like ab$cdefg$eurur. I
need to extract the right most part of the string from just right of
the $ sign. How do I do this?

\\\

Dim s1 As String = "ab$cdefg$eurur"
Dim s2 As String

s2 = Mid(s1, InStrRev(s1, "$") + 1)
///
 
Oenone said:
\\\

Dim s1 As String = "ab$cdefg$eurur"
Dim s2 As String

s2 = Mid(s1, InStrRev(s1, "$") + 1)
///
Dim s1 As String = "ab$cdefg$eurur"
Dim temp() as string = s1.split("$")
Dim result as string = temp(2)
 
This will get the characters(eurur) after the last $ or return all if there
are no $'s.

Dim str As String = "ab$cdefg$eurur"
str = str.Substring(str.LastIndexOf("$")+1)
 
John said:
I have a string with two $ sign in between, like ab$cdefg$eurur. I need to
extract the right most part of the string from just right of the $ sign. How
do I do this?

Besides all the other suggestions, you may have also:

Dim S1 As String = "ab$cdefg$eurur"
Dim S2 As String = S1.Substring(S1.LastIndexOf("$"c) + 1)

Regards,

Branco.
 
John said:
Hi

I have a string with two $ sign in between, like ab$cdefg$eurur. I need to
extract the right most part of the string from just right of the $ sign. How
do I do this?

Lots of answers, and it's great to see that no one offered a regex!
Perhaps our efforts here in the newsgroups are not all in vain...
 
Back
Top