-
January 20th, 2009, 08:16 AM
#1
Regular Expressions
Hi! Im wondering if someone could answer a really newbie question concerning regular expressions in c#. I have a string (stringPacket) containing an Ethernetpacket in hex and i want to put the first 6 characters in a variable called ethDestMac.
So far i have:
Regex regexPacket = new Regex(@"^(?<ethDestMac>[0-9a-f]{6})");
Match oMatch=regexPacket.Match(stringPacket);
ethDestMac = oMatch.Groups["ethDestMac"].ToString();
But that doesnt give me the correct answer. Would very much appreciate if someone could push me in the right direction on how to get my program to work.
Thanks!
-
January 20th, 2009, 11:58 AM
#2
Re: Regular Expressions
You don't need a regular expression for this, you can do this by using normal string manipulation functions e.g.
Code:
string first6 = stringPacket.Substring(0,6);
Darwen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|