473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C# RegEx - FlagSet check in integer

Is it possible to find if lower 1st bit and 2nd bit in an 32-bit integer is set using regular expression in C#

Example

1. Input Strings - 0, 1, 2 Result - Fai
2. Input Strings - 3, 7, Result - Fail
Nov 15 '05 #1
2 2635
AFAIK regular expressions don't have the ability to crack integers into
constituent components.
In other words there is no matching group that lets you specify bits, only
matching groups that let
you specify certain digits or strings of digits. Digits are represented as
character groups even, so
really you can only specify a string of characters that has the same matching
group as the characters
that represent numbers.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"CSharp" <an*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Is it possible to find if lower 1st bit and 2nd bit in an 32-bit integer is set using regular expression in C# ?
Examples

1. Input Strings - 0, 1, 2 Result - Fail
2. Input Strings - 3, 7, Result - Fail

Nov 15 '05 #2
I don't know the specifics of your need, but it would probably be easier to
do this check with an AND bit mask.

For example:
// Check the lower 2 bits
if((((i & 0x00000003) > 0) && (i & 0x00000003) < 4))
{
MessageBox.Show("One or both of the lower 2 bits is set");
}// where i is a System.Int32

"CSharp" <an*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
Is it possible to find if lower 1st bit and 2nd bit in an 32-bit integer is set using regular expression in C# ?
Examples

1. Input Strings - 0, 1, 2 Result - Fail
2. Input Strings - 3, 7, Result - Fail

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Tim Conner | last post by:
Is there a way to write a faster function ? public static bool IsNumber( char Value ) { if (Regex.IsMatch( Value.ToString(), @"^+$" )) { return true; } else return false; }
4
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said,...
17
by: steve | last post by:
here's the deal...cvs, tick encapsulted data. trying to use regex's to validate records. here's an example row: 'AD,'BF','132465','06/09/2004','','BNSF','A','TYPE','1278','','BR','2999',''...
3
by: jg | last post by:
I made a mistake somewhere in my vb code and I look, check and read against the articles and help on regex, I still can't find the mistake I made. I know my test string and the test patterns...
1
by: David | last post by:
I have rows of 8 numerical values in a text file that I have to parse. Each value must occupy 10 spaces and can be either a decimal or an integer. // these are valid - each fit in a 10 character...
4
by: Smokey Grindle | last post by:
I am writing a messaging app (email like) and want to check if a message has a RE: or FWD: already and if so put a RE: or FWD: type of prefix on it that increments automatically on each reply to...
11
by: Steve | last post by:
Hi All, I'm having a tough time converting the following regex.compile patterns into the new re.compile format. There is also a differences in the regsub.sub() vs. re.sub() Could anyone lend...
10
by: bullockbefriending bard | last post by:
first, regex part: I am new to regexes and have come up with the following expression: ((1|),(1|)/){5}(1|),(1|) to exactly match strings which look like this: 1,2/3,4/5,6/7,8/9,10/11,12 ...
8
by: Martin Nadoll | last post by:
hello, i need a regular expression for my form-validation: it should be allowed to fill a <input type="text"with any iteger number up to 500 or a integer number up to 500 followed by px...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.