471,328 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to build this pattern?

A string cannot include any of these symbols: ^ ~ \ & -- % | “ [ ] : ;
= * ? < #

if (Regex.IsMatch(someString, pattern))
MessageBox.Show("A string cannot include any of these symbols: ^ ~
\ & -- % | “ [ ] : ; = * ? < #")

How to build this pattern?
Please help!
Thank you.
Sep 10 '08 #1
5 1132
slishnevsky <sl*********@gmail.comwrote:
A string cannot include any of these symbols: ^ ~ \ & -- % | =3F [ ] : ;
= * ? < #

if (Regex.IsMatch(someString, pattern))
MessageBox.Show("A string cannot include any of these symbols: ^ ~
\ & -- % | =3F [ ] : ; = * ? < #")

How to build this pattern?
Do you have to do it with regular expressions? I mean, it's feasibly -
but using string.IndexOfAny is simpler.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Sep 10 '08 #2
On Sep 10, 5:20*pm, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
slishnevsky <slishnev...@gmail.comwrote:
A string cannot include any of these symbols: ^ ~ \ & -- % | =3F [ ] : ;
= * ? < #
if (Regex.IsMatch(someString, pattern))
* * MessageBox.Show("A string cannot include any of these symbols: ^ ~
\ & -- % | =3F [ ] : ; = * ? < #")
How to build this pattern?

Do you have to do it with regular expressions? I mean, it's feasibly -
but using string.IndexOfAny is simpler.

--
Jon Skeet - <sk...@pobox.com>
Web site:http://www.pobox.com/~skeet*
Blog:http://www.msmvps.com/jon.skeet
C# in Depth:http://csharpindepth.com
Indeed :)

Sep 10 '08 #3
string t = @"^ ~ \ & -- % | “ [ ] : ;= * ? < #";
Pattern = "^[" + t + "]+?";

Regex.IsMatch(someString, t)
"slishnevsky" <sl*********@gmail.comwrote in message
news:16**********************************@l43g2000 hsh.googlegroups.com...
A string cannot include any of these symbols: ^ ~ \ & -- % | “ [ ] : ;
= * ? < #

if (Regex.IsMatch(someString, pattern))
MessageBox.Show("A string cannot include any of these symbols: ^ ~
\ & -- % | “ [ ] : ; = * ? < #")

How to build this pattern?
Please help!
Thank you.
Sep 11 '08 #4
A string cannot include any of these symbols: ^ ~ \ & -- % | “ [ ] : ;
= * ? < #
if (Regex.IsMatch(someString, pattern))
* *MessageBox.Show("A string cannot include any of these symbols: ^~
\ & -- % | “ [ ] : ; = * ? < #")
try pattern "\\^|~|\\|&|--|%|\\||\"|\\[|\\]|:|;|=|>|<|#"

then
if (! Regex.IsMatch(someString, pattern))
MessageBox.Show("A string cannot include any of these
symbols: ^ ~ \ & -- % | “ [ ] : ; = * ? < #")

Regards,
-Ratnesh
S7 Software
Sep 11 '08 #5
On Sep 11, 5:13*pm, Ratnesh Maurya <ratneshmau...@gmail.comwrote:
A string cannot include any of these symbols: ^ ~ \ & -- % | “ [ ] : ;
= * ? < #
if (Regex.IsMatch(someString, pattern))
* *MessageBox.Show("A string cannot include any of these symbols:^ ~
\ & -- % | “ [ ] : ; = * ? < #")

try pattern *"\\^|~|\\\\|&|--|%|\\||\"|\\[|\\]|:|;|=|>|<|#"

then
if (! Regex.IsMatch(someString, pattern))
* * * * * * MessageBox.Show("A string cannot include any of these
symbols: ^ ~ \ & -- % | “ [ ] : ; = * ? < #")

Regards,
-Ratnesh
S7 Software
small correction
"\\^|~|\\|&|--|%|\\||\"|\\[|\\]|:|;|=|>|<|#"
Sep 11 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Steven T. Hatton | last post: by
2 posts views Thread by zbig555z | last post: by
3 posts views Thread by clintonG | last post: by
2 posts views Thread by Rudy Ray Moore | last post: by
3 posts views Thread by Julian | last post: by
6 posts views Thread by John Gabriel | last post: by
reply views Thread by rosydwin | last post: by

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.