Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 17th, 2006, 03:48 PM
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default Regular Expression Apostrophe Problem in .NET

I'm new to using Regular Expressions, but I'm trying to use them for form validation. Everything's going fine so far, except for names that contain an apostrophe (i.e. O'Dell).

This article http://msdn.microsoft.com/library/de...aght000001.asp, states that this code:
Regex.IsMatch(fname_form, "^[a-zA-Z'.\s]{1,40}$")

"...constrains an input name field to alphabetic characters (lowercase and uppercase), space characters, the single quotation mark (or apostrophe) for names such as O'Dell, and the period or dot character. In addition, the field length is constrained to 40 characters.".

But I'm getting this error when attempting to enter a name with an apostrophe:
Expected token 'eof' found 'NAME'. 'o'-->dell<--'

Huh? If anyone can let me know what I'm doing wrong, that would be great. Thanks.

KWilliams
Reply With Quote
  #2 (permalink)  
Old February 17th, 2006, 04:10 PM
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I decided that it would be smart to replace any apostrophe's with a question mark anyway for future use, so I just added a replace function like this:
lname_form = lname_form.replace("'","?")

...and I'll then change it back when displaying the data on a web page or email. Now I'm good-to-go. Thanks:)

KWilliams
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expression problem keyvanjan ASP.NET 2.0 Basics 0 May 28th, 2007 12:19 PM
regular expression problem muki XSLT 2 January 11th, 2006 06:04 AM
Regular Expression (Big Problem) vinod_yadav1919 Javascript How-To 6 November 3rd, 2004 05:24 AM
Regular expression problem ghalebro PHP How-To 1 August 24th, 2004 08:10 AM
Regular Expression problem Mitch PHP How-To 2 May 14th, 2004 07:43 AM



All times are GMT -4. The time now is 05:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.