473,383 Members | 1,813 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,383 software developers and data experts.

Is there a good RegEx expression for changing non-valid alphanumeric characters in a string to " "?

Tom
I have a poitionally delimited flat file (.txt) with large records being
prepared for uploading to a mainframe. I need to make sure that any invalid
characters within fields are translated into spaces. It seems as though
RegEx might be most appropriate for this.

Does anyone know the RegEx syntax?
Nov 16 '05 #1
3 1190
Here's a very good ebook on the subject:
http://www.amazon.com/exec/obidos/tg...books&n=507846

(I didn't write the book, nor do I have any connection with the author or
publisher. I bought the book to help me get through some text parsing, and
I found it to be a very good resource).
"Tom" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a poitionally delimited flat file (.txt) with large records being
prepared for uploading to a mainframe. I need to make sure that any invalid characters within fields are translated into spaces. It seems as though
RegEx might be most appropriate for this.

Does anyone know the RegEx syntax?

Nov 16 '05 #2
I bought the following book authored by Ben Forta a very well-known
and highly respected developer/author working for the enemy
-- Macromedia ;-) -- and highly recommend this book as it is the
best explanation of regular expression syntax I have ever read....

http://www.amazon.com/exec/obidos/tg...glance&s=books

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"J.Marsch" <je****@ctcdeveloper.com> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
Here's a very good ebook on the subject:
http://www.amazon.com/exec/obidos/tg...books&n=507846
(I didn't write the book, nor do I have any connection with the author or publisher. I bought the book to help me get through some text parsing, and I found it to be a very good resource).
"Tom" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a poitionally delimited flat file (.txt) with large records being prepared for uploading to a mainframe. I need to make sure that any

invalid
characters within fields are translated into spaces. It seems as though RegEx might be most appropriate for this.

Does anyone know the RegEx syntax?


Nov 16 '05 #3
"Tom" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a poitionally delimited flat file (.txt) with large records being
prepared for uploading to a mainframe. I need to make sure that any invalid characters within fields are translated into spaces. It seems as though
RegEx might be most appropriate for this.

Does anyone know the RegEx syntax?


The character class \W matches "any nonword character" - anything that is
not a-z, A-Z, or 0-9. So:

string foo = "hey!fix?this";
string bar = System.Text.RegularExpressions.Regex.Replace(foo, @"\W", "
");

You can buy a book, but I think the MSDN documentation on regular
expressions is pretty good.

Erik
Nov 16 '05 #4

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

Similar topics

4
by: M Wells | last post by:
Hi All, I couldn't find a regular expressions group to ask this in, so I thought I'd ask here as I'm a little familiar with php's regular expressions syntax. I have a comma delimited text...
77
by: Hunn E. Balsiche | last post by:
in term of its OO features, syntax consistencies, ease of use, and their development progress. I have not use python but heard about it quite often; and ruby, is it mature enough to be use for...
3
by: Phil396 | last post by:
I am trying to mix metacharacters and the literal versions in an expression and no matter what I try it does not work. Here is the code customer = Regex.Replace(customer,"$",""); I want to...
1
by: Terry Olsen | last post by:
I download xml logs from several servers every day and read the data out of them using the XmlTextReader. But about 10% of them each day throw exceptions because they are not well formed. I don't...
4
by: DSmith1974 | last post by:
Are lookarounds supported in the boost regex lib? In my VS6 project using boost 1.32.0 I can declare a regex as.. <code_snippet> std::wstring wstrFilename = L"01_BAR08"; boost::wregex...
5
by: =?Utf-8?B?SkF1bA==?= | last post by:
I am currently working on a project and need to get a return… even if that return is a failure. I must also add that I have no control over either the Regular Expression that will be used or the...
4
by: Henrik Dahl | last post by:
Hello! In my application I have a need for using a regular expression now and then. Often the same regular expression must be used multiple times. For performance reasons I use the...
4
by: pedrito | last post by:
I have a regex question and it never occurred to me to ask here, until I saw Jesse Houwing's quick response to Phil for his Regex question. I have some filenames that I'm trying to parse out of...
13
by: brad | last post by:
Still learning C++. I'm writing some regex using boost. It works great. Only thing is... this code seems slow to me compared to equivelent Perl and Python. I'm sure I'm doing something incorrect....
23
by: tkpmep | last post by:
I have a list that starts with zeros, has sporadic data, and then has good data. I define the point at which the data turns good to be the first index with a non-zero entry that is followed by at...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.