Showing posts with label follows. Show all posts
Showing posts with label follows. Show all posts

Wednesday, March 28, 2012

Substring and ()

Hello,

I have a string which looks as follows: "asdksdjfssdf@dotnet.itags.org.sdfsdfsdfsdfsdf.com (John Smith)"

How to create a substring with only the part which is between (), i.e., the name?

Thanks,

Miguel

you could either use thestring.indexof to find the locations of the parenthesis and then extract the substring..

or you could look at using regex:http://aspnet.4guysfromrolla.com/articles/022603-1.aspx


Consider

PublicFunction GetPersonsName(ByVal ItemTextAsString)AsString

' Sample data - expects constant format as provided, and without

' sure its not really possible anyway.

' "asdksdjfssdf@.sdfsdfsdfsdfsdf.com (John Smith)"

Dim SplitChars()AsChar = {"(",")"}

Return ItemText.Split(SplitChars)(1)' Returns John Smith

EndFunction

rgds,

Martin.

Substring and ()

Hello,
I have a string which looks as follows:
"asdksdjfssdf@dotnet.itags.org.sdfsdfsdfsdfsdf.com (John Smith)"
How to create a substring with only the part which is between (), i.e.,
the name?
Thanks,
MiguelThere are a couple of ways:
1. Use a Regular Expression
2. Split the string on '(' and remove the ')' from the resulting string
3. Find the position of '(' and ')' with Regex or string search and
substring using these two values to get start and end.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
****************************************
*********
Think outside of the box!
****************************************
*********
"shapper" <mdmoura@.gmail.com> wrote in message
news:1159644569.490605.218750@.k70g2000cwa.googlegroups.com...
> Hello,
> I have a string which looks as follows:
> "asdksdjfssdf@.sdfsdfsdfsdfsdf.com (John Smith)"
> How to create a substring with only the part which is between (), i.e.,
> the name?
> Thanks,
> Miguel
>

Substring and ()

Hello,

I have a string which looks as follows:
"asdksdjfssdf@dotnet.itags.org.sdfsdfsdfsdfsdf.com (John Smith)"

How to create a substring with only the part which is between (), i.e.,
the name?

Thanks,

MiguelThere are a couple of ways:

1. Use a Regular Expression
2. Split the string on '(' and remove the ')' from the resulting string
3. Find the position of '(' and ')' with Regex or string search and
substring using these two values to get start and end.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
*************************************************
Think outside of the box!
*************************************************
"shapper" <mdmoura@.gmail.comwrote in message
news:1159644569.490605.218750@.k70g2000cwa.googlegr oups.com...

Quote:

Originally Posted by

Hello,
>
I have a string which looks as follows:
"asdksdjfssdf@.sdfsdfsdfsdfsdf.com (John Smith)"
>
How to create a substring with only the part which is between (), i.e.,
the name?
>
Thanks,
>
Miguel
>