Hi Eric,
Ok, I don't know what is values of that string will always exist (will that
'For:' always be there?!?), so here is a very generic Regex that will grab
those 2 values:
Regex r= new Regex(
@"^[^,]+,\s+(?<numbers>\d+)(?<afterNumbers>[^,]+),.*$",
RegexOptions.IgnoreCase
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
you can use it like
string line = "For: Name-Location-40940, 1249V_S, 4120 City";
Match m = r.Match( line );
int numbers = int.Parse( m.Groups[ "numbers" ].Value );
string afterNumbers = m.Groups[ "afterNumber" ].Value;
Cheers!
Dave
----- Original Message -----
From: Eric Throckmorton
To: [email protected]
Sent: Wednesday, December 07, 2005 3:18 PM
Subject: RE: [AspNetAnyQuestionIsOk] Regular Expression -- retrieving a number
OK,
What i have so far is:
(For:)(.*[\w]+\b,) -that pulls the line up to:
For: Name-Location-40940, 1249V_S, (the second comma)
I have been trying through code and through the regex to get this split and
cannot.
Some help would be appreciated.
Thank-you,
Eric
"Falls, Travis D (HTSC, CASD)" <[EMAIL PROTECTED]> wrote:
Capture each item leading up to the "," in a back reference and then I
would process the back reference you need with another reg exp to split it;
tokenize it. If you get stuck send me your exp so far and I will take a stab
at it. I won't be able to do this until tomorrow afternoon though. HTH
Travis D. Falls | Consultant RAFT.Net IT | 860.547.4070 | [EMAIL
PROTECTED]
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] Behalf Of
e_throckmorton
Sent: Wednesday, December 07, 2005 2:57 PM
To: [email protected]
Subject: [AspNetAnyQuestionIsOk] Regular Expression -- retrieving a
number
Working with regular expressions, I can get the following line from a
text document:
For: Name-Location-40940, 1249V_S, 4120 City
What I need to grab out of there is:
1249V_S
And then disect that into:
1249
and
V_S
How can I do those things using regular expressions?
Thank-you,
E
Yahoo! Groups Links
*************************************************************************
This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information. If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited. If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************
SPONSORED LINKS
Basic programming language Computer programming languages
Programming languages Java programming language
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! Shopping
Find Great Deals on Gifts at Yahoo! Shopping
[Non-text portions of this message have been removed]
------------------------------------------------------------------------------
YAHOO! GROUPS LINKS
a.. Visit your group "AspNetAnyQuestionIsOk" on the web.
b.. To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
------------------------------------------------------------------------------
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/