473,472 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Create 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 2351

"Ron Brennan" <rb******@magma.ca> wrote in message
news:oO********************@magma.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********************@magma.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
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...
30
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 () {...
5
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...
17
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...
1
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
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...
5
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....
6
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
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
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
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...
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...
1
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,...
1
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...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.