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 19633
Use a regular expression:
Regex r = new Regex(@"\s");
dest = r.Replace(str, "");
Ken
"Julie" <ju***@nospam.c om> 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.c om> 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.ed u
"Ken Kolda" <ke*******@elli emae-nospamplease.co m> wrote in message news:OQ******** ******@TK2MSFTN GP11.phx.gbl... Use a regular expression:
Regex r = new Regex(@"\s"); dest = r.Replace(str, "");
Ken
"Julie" <ju***@nospam.c om> 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 tried to eliminate
it several ways, but it won't go away.
It looks like it's forcing at least one space (line break?) in after
each field, and then there's some mystery padding on the right that
also refuses to go away. I've put up a demo of...
|
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 filled out in the prior
page's form elements.
Naturally some users like to copy and paste text into the textarea box and
presumably do so from say a word processor program. Some Macintosh based
users I know of experience problems with foreign...
|
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 with no success.
Why doesn't this work and how do I do this?
Thanks!
|
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 spaces(if it more than once between two words).
Is there any function we have in C which will find out the tabs and
white spaces and returns the text in the follwong way -
| |
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 with the following elements
arr(0) = "MyString"
arr(1) = 40
arr(2) = "Hello world"
|
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 | characters. Basically i want to
build up a string along the lines of ^102|103|104|105$ where the number are
coming from the data table. This is easy enough and works fine.
Unfortunately the data values from the database are padded out with loads 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 the screen,
but for some bizarre reason when I try to substring out a series of bytes
(aka a fixed-length string or field) from a given option it squashes
everything up and corrupts the result.
|
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: 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: 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...
| |
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,...
|
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: 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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |