473,396 Members | 2,061 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,396 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 1189
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: nfr | last post by:
Default build directories seem to be somewhat different between C# and Visual Basic.NET. Both have "Debug" and "Release" directories under "obj". However, Visual Studio.NET defaults to a single...
5
by: | last post by:
Is it possible to extend this function to dynamically create a combo boxes from the db table....How would do this...I tried passing a 'Select' type to the function but got a blank entry....Any...
4
by: Steven T. Hatton | last post by:
Below is some code I wrote to get a better understanding of the dynamic verses static type resolution. My intention was to see if there was a way to use references for the static access to the...
9
by: Harry | last post by:
Hi there, does anyone know how I can build a regular expression e.g. for the string.search() function on runtime, depending on the content of variables? Should be something like this: var...
2
by: zbig555z | last post by:
Hello: I have written an ASP.net app that pulls settings from a database. Part of the setting definition is a regular expression that I want to use on the client via JavaScript for data...
3
by: clintonG | last post by:
Please provide your article reference(s) that document how to use DNF 1.1 panel controls to build a Wizard. I've seen and tried out the DNF 2.0 Wizard Control, I don't like the current...
2
by: Rudy Ray Moore | last post by:
How can I modify the project build order of a multi-project workspace under "Visual Studio .net 2003 7.1 c++"? I tried to modify the .sln by hand to influence the build order, but it didn't seem...
3
by: Julian | last post by:
Build.Net is a build tool that parses and builds VS.NET project files. Build.Net is run from the command line. It recursively searches a directory for VS.NET project files to build. This...
6
by: John Gabriel | last post by:
I have been obtaining the following error in the output window of the IDE: 1>mt.exe:general error c101008d:Failed to write the updated manifest to the resource of file "..\debug\test.exe". The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.