|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Extracting stringHi
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 =3D "ab$cdefg$eurur" str =3D str.Substring(0, str.IndexOf("$", 0)) On Mon, 10 Jul 2006 19:16:53 +0100, John <John@nospam.infovis.co.uk> wro= te: Show quoteHide quote > Hi -- => > I have a string with two $ sign in between, like ab$cdefg$eurur. I nee= d = > to > extract the right most part of the string from just right of the $ sig= n. = > How > do I do this? > > Thanks > > Regards > > Tiago Salgado http://www.foruns.org 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 Show quoteHide quote "John" <John@nospam.infovis.co.uk> wrote in message news:%238SuF0EpGHA.1140@TK2MSFTNGP05.phx.gbl... > 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 > John wrote:
> 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) /// -- (O)enone Oenone wrote:
> John wrote: Dim s1 As String = "ab$cdefg$eurur">> 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) > /// > 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) -- Show quoteHide quoteDennis in Houston "John" wrote: > 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 > > > John wrote:
> I have a string with two $ sign in between, like ab$cdefg$eurur. I need to Besides all the other suggestions, you may have also:> 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 = S1.Substring(S1.LastIndexOf("$"c) + 1) Regards, Branco. John wrote:
> Hi Lots of answers, and it's great to see that no one offered a regex!> > 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? Perhaps our efforts here in the newsgroups are not all in vain... -- Larry Lard Replies to group please When starting a new topic, please mention which version of VB/C# you are using
variable usage
combobox gives unexpected cast error Redrawing graphics in userControl - Button InputBox problems after upgrade regular expression problem Get Icon from CallingAssembly (or ...) ListView iteration order Don't understand this warning message window application refresh every minute Scrolling columns in datagrid |
|||||||||||||||||||||||