I currently use the following to remove embedded spaces from strings:
dest = str.Replace(" ", "");
and resort to something like the following to remove white space:
dest = str.Replace(" ", "").Replace("\t", "").etc.;
Is there a better, more efficient way? 3 19620
Use a regular expression:
Regex r = new Regex(@"\s");
dest = r.Replace(str, "");
Ken
"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com... I currently use the following to remove embedded spaces from strings:
dest = str.Replace(" ", "");
and resort to something like the following to remove white space:
dest = str.Replace(" ", "").Replace("\t", "").etc.;
Is there a better, more efficient way?
Ken Kolda wrote: Use a regular expression:
Regex r = new Regex(@"\s"); dest = r.Replace(str, "");
Ken
"Julie" <ju***@nospam.com> wrote in message news:40***************@nospam.com... I currently use the following to remove embedded spaces from strings:
dest = str.Replace(" ", "");
and resort to something like the following to remove white space:
dest = str.Replace(" ", "").Replace("\t", "").etc.;
Is there a better, more efficient way?
Excellent -- thanks!
Ya know, sometime I have GOT to learn more about regular expressions. I've never really been able to grasp the concept of them,
though I know they are very powerful.
--
Adam Clauss ca*****@tamu.edu
"Ken Kolda" <ke*******@elliemae-nospamplease.com> wrote in message news:OQ**************@TK2MSFTNGP11.phx.gbl... Use a regular expression:
Regex r = new Regex(@"\s"); dest = r.Replace(str, "");
Ken
"Julie" <ju***@nospam.com> wrote in message news:40***************@nospam.com... I currently use the following to remove embedded spaces from strings:
dest = str.Replace(" ", "");
and resort to something like the following to remove white space:
dest = str.Replace(" ", "").Replace("\t", "").etc.;
Is there a better, more efficient way?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Grumble |
last post by:
Hello all,
I want to read lines from a text file, where each line has the
following syntax:
token1:token2:token3
There could be white space between tokens and ':'
|
by: Jonathan Daggar |
last post by:
Hello,
I'm trying to put together a form with a very tight table formatting.
However, every time I put an text-type input field in, the browser
pads the area to the right of it with space. I've...
|
by: Peter O'Reilly |
last post by:
I have an HTML form with a textarea input box. When the user conducts a
post request (e.g. clicks the submit button), an HTML preview page is
presented to them with the information they have...
|
by: vbMark |
last post by:
I need to check for sentences that have a space before the period and
remove the space. I've tried:
$sentence = str_replace(" .", ".", $sentence);
but it does not work. I've tried other ways...
|
by: gopal srinivasan |
last post by:
Hi,
I have a text like this -
"This is a message containing tabs and white spaces"
Now this text contains tabs and white spaces. I want remove the tabs
and white...
|
by: Charles Law |
last post by:
I have a string similar to the following:
" MyString 40 "Hello world" all "
It contains white space that may be spaces or tabs, or a combination, and I
want to produce an array...
|
by: clickon |
last post by:
I am building up the validation expression for a RegularExpresionValidator
control by retreiving some values from a database and looping through the
DataTable to build and adding lots of |...
|
by: Richard Maher |
last post by:
Hi,
Can someone please show me how to tell Firefox to preseve white-space when
returning the selectList.option.value attribute?
I have change the style so that the white-space is preserved on...
|
by: mosesdinakaran |
last post by:
Can any one explain how the rule is applied for the following Regular
expression
$Str = 'the red king';
$Pattern = '/((red|white) (king|queen))/';
preg_match($Pattern,$Str,$Val);
Result:
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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,...
|
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...
|
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...
|
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...
| |