473,795 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regular Expressions question on whitespace

Hi,

I have a Regular Expression that will match the format a
user provides in a textbox.

Ex. User types Brown,Joe in the textbox

I would like the expression to have both whitespace and
non-whitespace options after the comma.

bebop

Regex regex4 = new Regex("^[A-Z][a-zA-Z]*\\,+\\S+(|\\S) +
([a-zA-Z]*)$");
Jul 21 '05 #1
2 1360
Just off the top of my head:

Regex myreg = new Regex(@"^[A-Z][\w]*\,[\s|\w](\w*)$");

Hope that helps.

Cheers,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Jul 21 '05 #2
When I build Regex's , I use a visual tool like
- Regex Designer - by Chris Sells
http://www.gotdotnet.com/Community/W...7-2ed2df2504a9
check out this picture of the UI:
http://www.sellsbrothers.com/tools/index.1.jpg

- RegEx, by Gerry Shaw
http://www.organicbit.com/regex/fog0000000019.html
But still, the testing of all of the combinations of input is not easy with
this sort of visual tool. A generic regex test harness is useful.
http://www.winisp.net/cheeso/srcview...gexVerifier.cs

-Dino

"Wim Hollebrandse" <wim@-NOSPAM-wimdows.net> wrote in message
news:uM******** *****@TK2MSFTNG P10.phx.gbl...
Just off the top of my head:

Regex myreg = new Regex(@"^[A-Z][\w]*\,[\s|\w](\w*)$");

Hope that helps.

Cheers,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/

Jul 21 '05 #3

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

Similar topics

2
1442
by: hu8 | last post by:
I must find a regular expression to find every declaration af a variable in a php programm..... I tried: /\$()*(\s|\S)\=(\s|\S)/is But it doesn't reall go :-(
5
11733
by: Andrew Dixon - Depictions.net | last post by:
Hi Everyone. I have been working on some code that strips the HTML code out of an HTML page leaving just the text on the page. At the moment this is what I have: // Strip all tags replacePattern = "<(.|\n)+?>"; pageHTML = pageHTML.replaceAll(replacePattern,""); //Remove any HTML specific characters (e.g. &quot; or &amp;)
1
4185
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) I'm still working on formal documentation, and in any case, such documentation isn't necessarily the...
11
3921
by: Martin Robins | last post by:
I am trying to parse a string that is similar in form to an OLEDB connection string using regular expressions; in principle it is working, but certain character combinations in the string being parsed can completely wreck it. The string I am trying to parse is as follows: commandText=insert into (Text) values (@message + N': ' + @category);commandType=StoredProcedure; message=@message; category=@category I am looking to retrive name value...
6
9018
by: Marc Scheuner [MVP ADSI] | last post by:
Folks, I've started using regular expressions for parsing some data string that come along - works quite nicely, however, as a newbie to RE, I'm still struggling with some special cases: 1) I get strings representing decimal values, and they have the following format: * first, a plus or minus sign * then, a number of numeric chars
1
4240
by: | last post by:
Hi, I have a Regular Expression that will match the format a user provides in a textbox. Ex. Brown,Joe in the textbox I would like the expression to have both whitespace and non-whitespace options after the comma.
1
366
by: Scott Schluer | last post by:
Hi all, I got a JavaScript function from a website that uses regular expressions to count the number of words in a textbox. I'm trying to replicate it with ASP.NET so I can run a second check on the server side to make sure the word count doesn't go over a specified number of words. I don't know anything about regular expressions so I'm hoping there's a glaring error that someone can just point out: The JavaScript function works...
9
3360
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use an app call The Regulator, which makes it pretty easy to build and test regular expressions. As a warning, I'm real weak with regular expressions. Let's say my regular expression is:
8
1562
by: Damo | last post by:
Hi, I'm new to this group and regular expressions. I want to extract text from a newspaper website using regular expressions and php I'm using this regular expression at the moment $regexp = "%<table cellspacing=\"0\" cellpadding=\"0\"(.+) <img height=\"1\" alt=\"Today's News\" />%s"; Each news story is in between those tags , So if I extract those chunks of html using
2
2137
by: John Nagle | last post by:
Regular expressions are compiled in ASCII mode unless Unicode mode is specified to "rc.compile". The difference is that regular expressions in ASCII mode don't recognize things like Unicode whitespace, even when applied to Unicode strings. For example, Unicode character 0x00A0 is a "NO-BREAK SPACE", which is a form of whitespace. It's the Unicode equivalent of HTML's "&nbsp;". This can create some strange bugs. Is the current default...
0
9673
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
10448
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10167
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
9046
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...
0
6784
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
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2922
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.