473,804 Members | 3,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Indentifying invalid char positions using RegExp

Good morning.

I would like to use one or more RegExp to validate country names as having
the first and last words beginning with an uppercase letter, intermediate
words beginning with either uppercase or lowercase, and all other characters
being lowercase characters. The difficult part is that I want to obtain save
the string positions of the invalid characters in an array, rather than just
obtain a true or false value.

Can anybody with more experience with Regular Expressions than me suggest
some code, sites, or approaches.

Thanks,
Ron

Jul 17 '05 #1
2 2369

"Ron Brennan" <rb******@magma .ca> wrote in message
news:oO******** ************@ma gma.ca...
Good morning.

I would like to use one or more RegExp to validate country names as having
the first and last words beginning with an uppercase letter, intermediate
words beginning with either uppercase or lowercase, and all other characters being lowercase characters. The difficult part is that I want to obtain save the string positions of the invalid characters in an array, rather than just obtain a true or false value.

Can anybody with more experience with Regular Expressions than me suggest
some code, sites, or approaches.

Thanks,
Ron


For example:

Turks and Caicos

Ron

Jul 17 '05 #2
""Ron Brennan" <rb******@magma .ca>" wrote in comp.lang.java:
"Ron Brennan" <rb******@magma .ca> wrote in message
news:oO******** ************@ma gma.ca...
Good morning.

I would like to use one or more RegExp to validate country names as having
the first and last words beginning with an uppercase letter, intermediate
words beginning with either uppercase or lowercase, and all other
characters being lowercase characters. The difficult part is that I want
to obtain save the string positions of the invalid characters in an array,
rather than just obtain a true or false value.

Can anybody with more experience with Regular Expressions than me suggest
some code, sites, or approaches.


For example:

Turks and Caicos


I strongly recommend you get the following book because it will really
help with understanding everything that Regular Expressions can do for you:

Mastering Regular Expressions, Second Edition
Jeffrey E. F. Friedl
O'Reilly & Associates, 2002
ISBN 0-596-00289-0

Note: If you're already familiar with using Regular Expressions in
PERL, then this book will definitely be more useful to you.

By the way, can you tell us a little bit about the project you're
working on? It would be interesting to know where this type of functionality
is needed.

--
Randolf Richardson, pro-active spam fighter - rr@8x.ca
Vancouver, British Columbia, Canada

Sending eMail to other SMTP servers is a privilege.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8257
by: Neil Morris | last post by:
Hi I have the following code that lists first names of people who's surnames are 'Morris'. What I am trying to do is search for first names that don't start at the beginning of the line ie. have the '' in the regExp object, but 'Neil' is matched even though it is next to(?) the start of line char(?) or should I say 'Neil' is the first 'word' of the string? here's the code <html>
30
5075
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () { srand(time(0)); int array_length; int count;
5
1576
by: Ron Brennan | last post by:
Good morning. I would like to use one or more RegExps to validate country names as having the first and last words beginning with an uppercase letter, intermediate words beginning with either uppercase or lowercase, and all other characters being lowercase characters. For example: Turks and Caicos The difficult part is that I want to obtain save the string positions of the
17
2025
by: Anders Christensen | last post by:
Hi. Suppose str is defined as follows char str = "012345678901"; Is it wrong to use functions such as printf("%s",str) strcmp(str2,str) strcpy(dest,str) (since str is an array of chars without the teminating \0)?
1
2920
by: Hemanth | last post by:
Hello, How do I find the first and last non-numeric char positions (using regexp) in an alphanumeric string? For example, 99ABC1A => should return 2, 6 DE8A1 => should return 0, 3 Thanks,
1
1764
by: Jason S | last post by:
Is there a way to get the position of multiple substrings that match a regexp without using closures? match() returns the substrings themselves, not the positions, and search() seems to only return the first position. Here's what seems to work (under Shanti Rao's jsdb.exe shell) but I get a bit nervous about using closures... function bind_cache(x) { return function (subs,ofs) { x.push(); return ""; }} x=; f=bind_cache(x);
5
2250
by: czechboy | last post by:
Hi, what is the fastest way to search for all occurences of a string in a very long string (from several KB to MB). What I want to get is an array of numbers with positions of each occurence. thanks
6
8387
by: =?ISO-8859-1?Q?Une_B=E9v?==?ISO-8859-1?Q?ue?= | last post by:
I wanted to test userAgent by a Regexp the goal : true if UA contains "AppleWebKit/528+ " or "AppleWebKit/525.12+ " note the final "+" false otherwise then i wrote :
4
3228
by: Paul Brettschneider | last post by:
Hello all, consider the following code: typedef char T; class test { T *data; public: void f(T, T, T); void f2(T, T, T);
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9157
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.