.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Given a Numeric range for a regex, how to get the minimum and maximum range values?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

If I create a random regex that is restricted to numeric ranges (leading zeros included), how can I determine the minimum and maximum values of the range from the regular expression itself?

For example, if the range is 011 - 453 and I had this regex: ^0*(1[1-9]|[2-9][0-9]|[1-3][0-9]{2}|4[0-4][0-9]|45[0-3])$

How can I reverse engineer out of the regex the min value - 011 and the max value = 453.

I want this in order to create an error message dialog that would say, "The value must be between MIN and MAX".

View Complete Post

More Related Resource Links

Regex validation of a range of digits



I need to check if a variable is inside of a range.

E.g. I'll like to check if variable "input" of type Int32 with the value 5 is in the range from 0 to 15.

I've tried with

if (Regex.IsMatch(input.ToString(), "([0-9]|1[0-5])"))


Console.WriteLine("In the Range");


It doesn't work :-(

Can somebody help,

ThanX :-)





Out of Range Values


CREATE TABLE #table1 (id INT , serial INT)

INSERT  INTO #table1 VALUES  ( 1 , 1 )

INSERT  INTO #table1 VALUES  ( 1 , 2 )

existing Values of a Measure not usable if other than the highest level of report-range-parameter is



I´m working on some new reports with SSRS 2008. Until yesterday I was making good progress. Then SSRS stopped behaving sensible...

I´ve got a measure "Share_EA_completed" which bases on another measure "EAs" and contains the share of completed EAs of the total of EAs. That measure works fine, if I select "All" in the report-parameter. If other levels (such as "Region xy" or "Team 37 of Region xy") are selected, the formula

=FormatPercent(Aggregate(Fields!Share_EA_completed.Value) -

gives back "0,00%", which is totally nonsense because if I run the Query of that Dataset in the query designer, I can see, that there are values for each team, and each region.

Does anybody know, how the bloody h... this is possible? I tried everything (publishing the calculated measure again, starting Visual Studio again, rerunning the query etc) but nothing works. Does anybody have an idea?


As always your help would be much appreciated!



DateTime values in external lists must fall within the range of 1/1/1900 and 12/31/8900


I have a WCF service and I have setup a BCS External Content Type to. All working fine, I have created a default list which displays the list of records. Problem is though one of the fields in the WCF is a datetime and if it has a value then all is fine but when you set the datetime field to nothing in the WCF I get the list showing all right but when I click on the record to get the default item form I get the following error. If I use a infopath form as default then it fails.:

DateTime values in external lists must fall within the range of 1/1/1900 and 12/31/8900. This form cannot be displayed because the external item contains this date: 01/01/0001 00:00:00

Obviously the datetime field minimum value is 1/1/0001 or something like that. Doesn't like nullable date fields. I don't want to set the field to 1/1/1900 as I want the default item form to display 1/1/1900 as a null or empty, don't want to make the field string as having the date fields in the list helps with sorting. I don't want to create specific list webpart or form at this stage but use the default list a form the Sharepoint designer creates.

Any ideas on how to handle or make null datetime field go back to the ECT?



ListViewControl - how to group items by their value, for eg. date range



I have a table containing courses, columns are 

Name - "Yoga Classes"

DateStart - "2/23/2010"

DateEnd - "2/24/2010"

I am using ListView Control to bind it, is there a way to display them and group them by Month? 

for eg.


Piano Class (10th Jan 2010 - 11th Jan 2010)
Guitar Class (10th Jan 2010 - 11th Jan 2010)


Yoga Class (15th Feb 2010 - 16th Feb 2010)

Thanks for help.

System.DateTime.AddDays: Value to add was out of range.


I'm getting the following error:

[ArgumentOutOfRangeException: Value to add was out of range.
Parameter name: value]
   System.DateTime.Add(Double value, Int32 scale) +7657639
   System.DateTime.AddDays(Double value) +19

The line from which this error originates has the following code:

expires = Now.AddDays(30)

It occurs irregularly and irreproducably. The server date/time is correct and set to GMT. I've heard that it could be some curiosity to do with timezones, but that is speculative.

It seems that we're some time from the year 10,000 yet, so I can't understand why adding thirty days to the current time could cause this! Any ideas? Culture settings perhaps?

'Value' should be between 'minimum' and 'maximum'.


I'm attempting to invoke with parameters:


Dim thing2 As New mydelsubPBStep(AddressOf pbStep)

Me.Invoke(thing2, "setMax", dt.Rows.Count)      <---- this is where the error occurs


the delegate looks like this:

Private Delegate

How i find out light and dark color range??



I am showing preview of text in text box.

But if text color is light(Like white) and i want to show that text preview than text is not visible because textbox background color is white.

Can i get the range of dark and light color so i'll change textbox backgroun color accordingly.

Thanks in advance.

Calculated Columns in a Form Library receive error: Value does not fall within the expected range.


I have a forms library that posts the date the form was created. We would like to create a calculated column that allows us to look at these forms based on the month and year they were created. I had created a calculated column that extracts the month and replaces the number with a text string by using an if statement; "IF(MONTH([Proposal Date])=1,"January","") It goes on to evaluate each month and replace the number with the text string. This formula worked for quite some time, though now when I try to add any calculated columns or edit any existing calculated columns on this form library I receive the following error: Value does not fall within the expected range. Now my existing calculated columns (like the one above) do not work and I can not create new calcualted columns. Any insight would be awesome as this has been plaguing me for a couple of months now.

When create a suvery using type Rating Scale, is it possible to create 5 range text?


When create a suvery using type Rating Scale, is it possible to create 5 range text?

Default range text only show 3 fields

Sql DateTime2 to .NET DateTime conversion results in out-of-range exception

I posted it in C# General because I thought that the subject was not Sql Smo related, although I use Smo extensively even in this routine for connection. Unfortunately after a few days no constructive suggestion has been advanced. Two posts the thread collected are not helpful. I am wondering if Alok or someone else with the status of MSFT Sql Server developers take a look at this very importan problem for me which became a stumbling block.Thanks. AlexB - Win_7 Pro64, SqlSer64 WinSer64

Need help in Date Range

HI Guys I need help to write a query I have a table Employee: empIDEmployeeName Task StartDt                                EndDt     1      xxx                  1    1950-01-01 00:00:00.000 1979-12-31 00:00:00.000     2     yyy                  2    1980-01-01 00:00:00.000 2009-06-30 00:00:00.000     3      aaa                 3    2009-06-30 00:00:00.000 2010-01-31 00:00:00.000     4     bbb                  4    2010-02-01 00:00:00.000 null when I pass one variable with date like 20070101 I need check the date ranges and get the exact record(this case 2nd records)

"Out-of-Range" Error When Passing DateTime (DD/MM/YYYY) into Stored Procedure

Hi everybody, I hope some of you will be able to help me regarding this datetime problem. The query in the stored procedure doesn't accept DD/MM/YYYY format, although all dates are being saved in the format of DD/MM/YYYY hh:mm:ss. Example of query that throws the error: @sDate = '31/8/2010' @eDate = '1/9/2010' SELECT * FROM tb_Schedule where scheduledate >= @sDate and scheduledate <= @eDate  Error:  The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value FYI, the SQL Server 2005 is defaulted to British English(2057)for all logins and the DB server itself and my server Regional and Language is set to English (United Kingdom). Any help will be appreciated. Thank you very much.  

add two numeric values

Hi, I'm trying to add two numeric values, where the one is a parameter, like this: numvalue1=numvalue1+@numvalue2 I get the error: operator does not exist:  numeric + @ numeric Then how can I add this values? I use vb.net, where I define parameters with the @ mark.

Value does not fall within the expected range.

I am trying to upload a csv file into a sharepoint list. (as demonstrated in SDK sample that i downloaded from here http://www.microsoft.com/click/SharePointDeveloper/html/Default.html)                 //open the CSV file for reading using (StreamReader fileRdr = File.OpenText(paramFileName)) { // connect to the site collection using (SPSite spSite = new SPSite(paramWeb)) { //open the web using (SPWeb spWeb = spSite.OpenWeb()) { //get the List from the site SPList spList = spWeb.Lists[paramList]; //read the files in the header string line = fileRdr.ReadLine(); string[] fieldNames = line.Split(splitArray); //get an Array of field from the List - this assumes that the fields name match // we need the field id when inseting rows SPField[] spFields = new SPField[fieldNames.Length]; for (int looper = 0; looper < fieldNames.Length; looper++) { string strName = fieldNames[looper];

Question Regarding Date Range

I have a requirement to confirm how many employees were 'active' on a given date.  The employee table which I'm using contains the following fields (among others):  1.   Row_Start_Date (when an employee started with the company) 2.  Row_End_Date (when an employee terminated with the company (if applicable)) What would be the best way to design this?  For example, let's say an employee started on 1/1/2010 (Row_Start_Date) and is still employeed (Row_End_Date is null).  If an analyst wants to see how many employees were active on 5/1/2010, how do I design it so that this employee is counted.  If I build a date dimension off of Row_Start_Date, then this employee would be reflected on 1/1/2010, but not on 5/1/2010.  Hopefully this makes sense, and I appreciate any assistance/suggestions in advance... KoleKRS

Export Data to Excel Based on Date Range

I have data from multiple tables that I would like to display in a gridview via a stored procedure.  I need to select the data based on a date range and display it.  Once displayed I need to include a button that would allow the user to export the gridview data to an excel spreadsheet.  Does anyone have an out of the box solution or know of a tutorial I can use to accomplish this feat?  I am currently using 2.0 for this project. I am newish to .net. Thanks in advance. Here is my stored procedure that calls the data from multiple tables.USE [DATABASENAME] GO /****** Object: StoredProcedure [dbo].[GetUsersAll] Script Date: 09/03/2010 08:20:23 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[GetUsersAll] AS SELECT aspnet_Users.UserName, aspnet_Membership.Email, Team.Name, MemberTeamRole.InsertDate, MemberTeamRole.ManagerApprovedDate, MemberTeamRole.RegistrarApprovedDate, MemberTeamRole.RoleName, MemberInfo.firstname, MemberInfo.lastname FROM aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId INNER JOIN MemberInfo ON aspnet_Users.UserId = MemberInfo.memberid LEFT OUTER JOIN MemberTeamRole ON aspnet_Membership.UserId = MemberTeamRole
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend