List Info

Thread: Translating System.data.DbType to RegEx Expressions




Translating System.data.DbType to RegEx Expressions
country flaguser name
United States
2007-09-10 15:46:42
I'm working on a project to validate user input against an
expected
DbType of the System.Data.DbType enumeration.  Please see
the
"Members" section of this page:

http://msdn2.microsoft.com/en-us/library/system.
data.dbtype.aspx

I'm not sure if there is a direct regular expression for
each member,
but hoping so.  So starting with the first item there, is
there an
appropriate Regex pattern for:

AnsiString
A variable-length stream of non-Unicode characters ranging
between 1
and 8,000 characters.

I came up with:  [.]{1,8000}
(I'm sure this is poorly written, as I am a newbie to
regex!)

Thanks,
Karl..


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Translating System.data.DbType to RegEx Expressions
country flaguser name
United States
2007-09-10 15:51:41
Karl,

A couple of comments -- I'll bet empty strings are also
valid, I've
never seen a database "string" type that didn't
support the empty
string.  So you might want

.{0,8000}

You don't want the square brackets [] around the dot.  The
square
brackets are for creating character classes like [0-9], or
[a-z].  [.]
will actually match a dot, not any character, since the dot
loses its
special meaning inside the square brackets.


On Sep 10, 2:46 pm, kstubs <kst...gmail.com> wrote:
> I'm working on a project to validate user input against
an expected
> DbType of the System.Data.DbType enumeration.  Please
see the
> "Members" section of this page:
>
> http://msdn2.microsoft.com/en-us/library/system.
data.dbtype.aspx
>
> I'm not sure if there is a direct regular expression
for each member,
> but hoping so.  So starting with the first item there,
is there an
> appropriate Regex pattern for:
>
> AnsiString
> A variable-length stream of non-Unicode characters
ranging between 1
> and 8,000 characters.
>
> I came up with:  [.]{1,8000}
> (I'm sure this is poorly written, as I am a newbie to
regex!)
>
> Thanks,
> Karl..


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Translating System.data.DbType to RegEx Expressions
country flaguser name
United States
2007-09-10 16:07:34
Thanks!  I've heard it is bad (scarry) practice to use the
dot.  Is
your advice to not use the dot?  Also, what is your take on
uni-code?
The definition actually calls out non-unicode characters.

On Sep 10, 1:51 pm, russ <black.russ...gmail.com> wrote:
> Karl,
>
> A couple of comments -- I'll bet empty strings are also
valid, I've
> never seen a database "string" type that
didn't support the empty
> string.  So you might want
>
> .{0,8000}
>
> You don't want the square brackets [] around the dot. 
The square
> brackets are for creating character classes like [0-9],
or [a-z].  [.]
> will actually match a dot, not any character, since the
dot loses its
> special meaning inside the square brackets.
>
> On Sep 10, 2:46 pm, kstubs <kst...gmail.com> wrote:
>
>
>
> > I'm working on a project to validate user input
against an expected
> > DbType of the System.Data.DbType enumeration. 
Please see the
> > "Members" section of this page:
>
> >http://msdn2.microsoft.com/en-us/library/system.
data.dbtype.aspx
>
> > I'm not sure if there is a direct regular
expression for each member,
> > but hoping so.  So starting with the first item
there, is there an
> > appropriate Regex pattern for:
>
> > AnsiString
> > A variable-length stream of non-Unicode characters
ranging between 1
> > and 8,000 characters.
>
> > I came up with:  [.]{1,8000}
> > (I'm sure this is poorly written, as I am a newbie
to regex!)
>
> > Thanks,
> > Karl..- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Translating System.data.DbType to RegEx Expressions
country flaguser name
United States
2007-09-10 16:12:57
There's nothing really scary about the dot.  I use it all
the time.
One other detail though with the dot...

The dot will normally not match end-of-line characters
(rn), unless
you use the /s modifier (if perl is your regex language,
"DOT_ALL" in
Java -- other languages have similar ways to set this
option)

I don't know about unicode.  I'd consult the documentation
for your
regex library and run a few experiments.

On Sep 10, 3:07 pm, kstubs <kst...gmail.com> wrote:
> Thanks!  I've heard it is bad (scarry) practice to use
the dot.  Is
> your advice to not use the dot?  Also, what is your
take on uni-code?
> The definition actually calls out non-unicode
characters.
>
> On Sep 10, 1:51 pm, russ <black.russ...gmail.com> wrote:
>
> > Karl,
>
> > A couple of comments -- I'll bet empty strings are
also valid, I've
> > never seen a database "string" type that
didn't support the empty
> > string.  So you might want
>
> > .{0,8000}
>
> > You don't want the square brackets [] around the
dot.  The square
> > brackets are for creating character classes like
[0-9], or [a-z].  [.]
> > will actually match a dot, not any character,
since the dot loses its
> > special meaning inside the square brackets.
>
> > On Sep 10, 2:46 pm, kstubs <kst...gmail.com> wrote:
>
> > > I'm working on a project to validate user
input against an expected
> > > DbType of the System.Data.DbType enumeration.
 Please see the
> > > "Members" section of this page:
>
> > >http://msdn2.microsoft.com/en-us/library/system.
data.dbtype.aspx
>
> > > I'm not sure if there is a direct regular
expression for each member,
> > > but hoping so.  So starting with the first
item there, is there an
> > > appropriate Regex pattern for:
>
> > > AnsiString
> > > A variable-length stream of non-Unicode
characters ranging between 1
> > > and 8,000 characters.
>
> > > I came up with:  [.]{1,8000}
> > > (I'm sure this is poorly written, as I am a
newbie to regex!)
>
> > > Thanks,
> > > Karl..- Hide quoted text -
>
> > - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Translating System.data.DbType to RegEx Expressions
country flaguser name
United States
2007-09-10 16:37:59
Ok, the Stream value types are tricky, I will not wory about
those too
much.  To begin with, I'll not validate these input field
types, I'll
let the database throw back an error.
So onto the byte field type, which is a valid value if
between 1 and
255.  Since I am new to regex, I can write the regex pattern
of 1 to
999 like this:

[1-9][0-9]{1,3}

(thinking that is correct)  well, this is probably more
correct, in my
case, expecting whole words/lines only so:
^[1-9][0-9]{1,3}$

So then, how do you define a "max" value?


On Sep 10, 2:12 pm, russ <black.russ...gmail.com> wrote:
> There's nothing really scary about the dot.  I use it
all the time.
> One other detail though with the dot...
>
> The dot will normally not match end-of-line characters
(rn), unless
> you use the /s modifier (if perl is your regex
language, "DOT_ALL" in
> Java -- other languages have similar ways to set this
option)
>
> I don't know about unicode.  I'd consult the
documentation for your
> regex library and run a few experiments.
>
> On Sep 10, 3:07 pm, kstubs <kst...gmail.com> wrote:
>
>
>
> > Thanks!  I've heard it is bad (scarry) practice to
use the dot.  Is
> > your advice to not use the dot?  Also, what is
your take on uni-code?
> > The definition actually calls out non-unicode
characters.
>
> > On Sep 10, 1:51 pm, russ <black.russ...gmail.com> wrote:
>
> > > Karl,
>
> > > A couple of comments -- I'll bet empty
strings are also valid, I've
> > > never seen a database "string" type
that didn't support the empty
> > > string.  So you might want
>
> > > .{0,8000}
>
> > > You don't want the square brackets [] around
the dot.  The square
> > > brackets are for creating character classes
like [0-9], or [a-z].  [.]
> > > will actually match a dot, not any character,
since the dot loses its
> > > special meaning inside the square brackets.
>
> > > On Sep 10, 2:46 pm, kstubs <kst...gmail.com> wrote:
>
> > > > I'm working on a project to validate
user input against an expected
> > > > DbType of the System.Data.DbType
enumeration.  Please see the
> > > > "Members" section of this
page:
>
> > > >http://msdn2.microsoft.com/en-us/library/system.
data.dbtype.aspx
>
> > > > I'm not sure if there is a direct
regular expression for each member,
> > > > but hoping so.  So starting with the
first item there, is there an
> > > > appropriate Regex pattern for:
>
> > > > AnsiString
> > > > A variable-length stream of non-Unicode
characters ranging between 1
> > > > and 8,000 characters.
>
> > > > I came up with:  [.]{1,8000}
> > > > (I'm sure this is poorly written, as I
am a newbie to regex!)
>
> > > > Thanks,
> > > > Karl..- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Translating System.data.DbType to RegEx Expressions
country flaguser name
United States
2007-09-11 11:59:16
My expression for Max value of 255 (min value of 0)
^(0?[1-9]?|1[0-9][0-9]|2[0-5][0-9]|25[0-5])$

Now working on currency type, this will be a doozy!
A currency value ranging from -2 63 (or
-922,337,203,685,477.5808) to
2 63 -1 (or +922,337,203,685,477.5807) with an accuracy to a
ten-
thousandth of a currency unit.

I actually may not regex that one, I'll just test the
overall form,
I'm thinking that this might be best practice anyhow, to not
test min
and max values...


On Sep 10, 2:37 pm, kstubs <kst...gmail.com> wrote:
> Ok, the Stream value types are tricky, I will not wory
about those too
> much.  To begin with, I'll not validate these input
field types, I'll
> let the database throw back an error.
> So onto the byte field type, which is a valid value if
between 1 and
> 255.  Since I am new to regex, I can write the regex
pattern of 1 to
> 999 like this:
>
> [1-9][0-9]{1,3}
>
> (thinking that is correct)  well, this is probably more
correct, in my
> case, expecting whole words/lines only so:
> ^[1-9][0-9]{1,3}$
>
> So then, how do you define a "max" value?
>
> On Sep 10, 2:12 pm, russ <black.russ...gmail.com> wrote:
>
>
>
> > There's nothing really scary about the dot.  I use
it all the time.
> > One other detail though with the dot...
>
> > The dot will normally not match end-of-line
characters (rn), unless
> > you use the /s modifier (if perl is your regex
language, "DOT_ALL" in
> > Java -- other languages have similar ways to set
this option)
>
> > I don't know about unicode.  I'd consult the
documentation for your
> > regex library and run a few experiments.
>
> > On Sep 10, 3:07 pm, kstubs <kst...gmail.com> wrote:
>
> > > Thanks!  I've heard it is bad (scarry)
practice to use the dot.  Is
> > > your advice to not use the dot?  Also, what
is your take on uni-code?
> > > The definition actually calls out non-unicode
characters.
>
> > > On Sep 10, 1:51 pm, russ
<black.russ...gmail.com> wrote:
>
> > > > Karl,
>
> > > > A couple of comments -- I'll bet empty
strings are also valid, I've
> > > > never seen a database "string"
type that didn't support the empty
> > > > string.  So you might want
>
> > > > .{0,8000}
>
> > > > You don't want the square brackets []
around the dot.  The square
> > > > brackets are for creating character
classes like [0-9], or [a-z].  [.]
> > > > will actually match a dot, not any
character, since the dot loses its
> > > > special meaning inside the square
brackets.
>
> > > > On Sep 10, 2:46 pm, kstubs
<kst...gmail.com> wrote:
>
> > > > > I'm working on a project to
validate user input against an expected
> > > > > DbType of the System.Data.DbType
enumeration.  Please see the
> > > > > "Members" section of this
page:
>
> > > > >http://msdn2.microsoft.com/en-us/library/system.
data.dbtype.aspx
>
> > > > > I'm not sure if there is a direct
regular expression for each member,
> > > > > but hoping so.  So starting with
the first item there, is there an
> > > > > appropriate Regex pattern for:
>
> > > > > AnsiString
> > > > > A variable-length stream of
non-Unicode characters ranging between 1
> > > > > and 8,000 characters.
>
> > > > > I came up with:  [.]{1,8000}
> > > > > (I'm sure this is poorly written,
as I am a newbie to regex!)
>
> > > > > Thanks,
> > > > > Karl..- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text
-
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )