Re: Regular Expression Help

From: Karl (_at_)
Date: 09/24/04


Date: Thu, 23 Sep 2004 20:24:42 -0400

Just so I'm clear, you want to limit on a certain character...such as 10 'a'
or more and it fails..but not necessarily in a row...so like
abaaaaacasaaaaaadasdsa would fail 'cuz in the totallity of the string there
are more than 10 'a'?

Karl

-- 
MY ASP.Net tutorials
http://www.openmymind.net/
"tmeister" <tmeister@discussions.microsoft.com> wrote in message
news:6C44F1C1-E097-449B-914F-BC306D9A57A1@microsoft.com...
> Part of the problem is that I have a web application that builds forms
> dynamically.  I then allow for validation routines for the given controls.
> For validation the system allows for multiple regular expressions for each
> control if needed and the form.  When someone posts their data I loop
through
> all of the controls and then pull their specific validation requirements
from
> the database.
>
> Let me know if you know what the regular expression would be to limit X
> number of characters in a string.
>
> Thanks
>
> "Karl" wrote:
>
> > Todd,
> > I'm almost positive you'll be better off going ToCharArray() and looping
> > through the char array....something like:
> >
> > public static bool HasTooManyOfASingleCharacter(string source, char
> > character, int max) {
> >    char[] array = source.ToCharArray();
> >    int count = 0;
> >    for (int i = 0; i < array.Length; ++i ){
> >       char c = array[i];
> >       if (c == character){
> >          ++count;
> >          if (count > max){
> >             return true;
> >          }
> >       }
> >    }
> >    return false;
> > }
> >
> >
> > -- 
> > MY ASP.Net tutorials
> > http://www.openmymind.net/
> >
> >
> > "tmeister" <tmeister@discussions.microsoft.com> wrote in message
> > news:2F281AEA-4CD7-4762-BFCB-5F704BE88463@microsoft.com...
> > > I am in need of a regular expression that tests and fails if there are
14
> > or
> > > more of a character in the test string.  There can be up to 13 of
these
> > > characters in the string and any other characters, but at the 14th of
this
> > > character it should fail.
> > >
> > > Thanks,
> > >
> > > Todd Meister
> >
> >
> >


Relevant Pages

  • Re: Regular Expression Help
    ... I then allow for validation routines for the given controls. ... > public static bool HasTooManyOfASingleCharacter(string source, ... >> character it should fail. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Why use asp controls instead of HTML inputs?
    ... You can certainly implement your own client-side validation model, ... FTP Client Classes, Enhanced Data Controls, much more. ... ASP.Net uses a programming model which is more strict than the Classic ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Form Field Validation On The Fly
    ... Allen Browne - Microsoft MVP. ... You cannot use the events of the controls, ... >> Private Sub Form_BeforeUpdate ... >> only validation I require is that they are not empty. ...
    (microsoft.public.access.formscoding)
  • Re: Extract domain names out of URLs
    ... Match the regular expression below and capture its match into backreference ... Between zero and one times, as many times as possible, giving back as needed ... A character in the range between ?A? ...
    (microsoft.public.excel)
  • Can anyone write this recursion for simple regexp more beautifully and clearly than the braggarts
    ... I know that lisp eval is written more clear than this recursion below ... The Practice of Programming ... The problem was that any existing regular expression package was far ... c Matches any literal character c. ...
    (comp.lang.c.moderated)

Loading