hi
I have a string from which I would like to purge all whitespaces,
non-english letters and special characters. I know I can use
String.TrimStar t(char[]) and then provide a list of all unwanted
characters, but the list will have to be large and cumbersome to
maintain. Is there a way to specify only_keep("A-z" && "0-9") or
something similar?
Thanks in advance
Nicki Carstensen
remove the car 3 34842
Nicki Carstensen <ni***@FORDbigf oot.com> wrote: I have a string from which I would like to purge all whitespaces, non-english letters and special characters. I know I can use String.TrimStar t(char[]) and then provide a list of all unwanted characters, but the list will have to be large and cumbersome to maintain. Is there a way to specify only_keep("A-z" && "0-9") or something similar?
Regex.Replace will probably do what you want, or you could fairly
easily hand-code a routine to do what you want. Bear in mind, however,
that "letters" contains much more than A-Z for the international
community - make sure you know exactly what you want to achieve before
you start.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi,
It could be as simple as this: ( not tested )
StringBuilder sb = new StringBuilder ();
for( int i=0; i< string.Length; i++ )
if ( (string[i]>='0' and string[i]<='9' ) || (string[i]>='A' and
string[i]<='z' ) )
sb.Append( string[i] );
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Nicki Carstensen" <ni***@FORDbigf oot.com> wrote in message
news:uH******** ******@TK2MSFTN GP10.phx.gbl... hi I have a string from which I would like to purge all whitespaces, non-english letters and special characters. I know I can use String.TrimStar t(char[]) and then provide a list of all unwanted characters, but the list will have to be large and cumbersome to maintain. Is there a way to specify only_keep("A-z" && "0-9") or something similar?
Thanks in advance
Nicki Carstensen remove the car
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:Og******** *****@TK2MSFTNG P11.phx.gbl... Hi,
It could be as simple as this: ( not tested )
StringBuilder sb = new StringBuilder (); for( int i=0; i< string.Length; i++ ) if ( (string[i]>='0' and string[i]<='9' ) || (string[i]>='A' and string[i]<='z' ) ) sb.Append( string[i] );
The above won't work because there may be special characters (such as [
and ]) in between A and z. Moreover, if you want the code to work for
non-English languages too, better use:
StringBuilder sb = new StringBuilder ();
for (int i=0; i< string.Length; i++)
if (char.IsLetterO rDigit(string[i])
sb.Append(strin g[i]);
Regards,
Sami This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ken |
last post by:
I am trying to create one image using JavaScript; then later in the script
remove the image - not just remove the src.
The following creates the image, but I have been unable to remove it.
How do I structure
document.getElementById('num1').removeChild(image_display); ?
<input type=file name="picture1" onChange="image(this.value, 'num1');"
Id="pt1">
<div id='num1'></div>
|
by: Oberon |
last post by:
I have a large HTML document. It has hundreds of <span>s which
have no attributes so these <span>s are redundant.
How can I remove these tags automatically?
The document also has <span>s with style attributes that I don't
want to remove.
|
by: Phil Powell |
last post by:
URL: http://www3.brinskter.com/soa/soa_samp.asp?refURL=valsignalandet
This URL produces a nice page with form material to produce
user-inputted band search information
Problem is that Brinkster interferes with the HTML resultset by
embedding their annoying ads all over the place.
How on earth do I remove them??
|
by: ElGordo |
last post by:
I was recently given .Net project files to work on. When I open the
Solution file in VS.Net, I always get the message:
"The solution appears to be under source control, but its binding
information cannot be found. It is possible that the MSSCCPRJ.SCC file or
another item that holds the source control settings for the solution, has
been deleted. Because it is not possible to recover this missing information
automatically, the projects...
|
by: Henry Combrinck |
last post by:
Hello all
I've been approached by the development people about removing the 'public'
schema. They complain about having to manually remove the 'public_' tag
from table names generated by their development software whenever they
link to PG via ODBC.
Renaming or using another schema is not what they're after either.
1. If it is possible to remove the public schema, what are the
| |
by: Andrew R |
last post by:
Hi
I'm creating a series of forms, each with with around 15-20 text boxes.
The text boxes will show data from tables, but are unbound to make them
more flexible.
I want the form to be used for both adding new data and modifying
existing data. I have created a save button on the form.
When the user clicks the save button, the code checks to see if there
|
by: Jarry |
last post by:
I was editing a huge XML file that a friend of mine had made and I
didn't need some of the tags. WHen I was finished editing it, I
realised I had a lot of information between tags, in no man's land. eg:
<team>
<player>
<name>David Beckham</nameREAL MADRID
<positionRight Midfield </position>
</player>
</team>
|
by: Mark Poppers |
last post by:
Assume the following sequence of user actions starting with a Form and an e.g. StatusStrip:
1.) User doubleclicks on the StatusStrip
2.) VisualStudio jumps to the new generated source code
mystatusstrip_itemClicked() { ..... }
3.) The user deletes this function from source code (because he decide not to add such an event)
4.) "Rebuild of source code"
5.) An error appears:
|
by: llothar |
last post by:
I'm afraid that the GIL is killing the usefullness of python for some
types of applications now where 4,8 oder 64 threads on a chip are here
or comming soon.
What is the status about that for the future of python?
I know that at the moment allmost nobody in the scripting world has
solved this problem, but it bites and it bites hard. Only groovy as a
Java Plugin has support but i never tried it. Writing an interpreter
that does MT this...
|
by: Allen Chen [MSFT] |
last post by:
Hi Richard,
Quote from Richard==================================================
However I also want to be able to remove the
panes. I have tried to include this, but find that when I first add the
pane
the remove event does not get handled, though thereafter it is handled
without problems.
==================================================
|
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...
| |
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,...
|
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...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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();...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |