473,772 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing excess white space

I am building up the validation expression for a RegularExpresio nValidator
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|10 5$ 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
spaces at the end which builds a string like ^102 |103 |104
|104 |$ which doesn't seem to work for the validation expression.
How do i remove the extraneus white space from the end of data before adding
it to the string variable. Bearing in mind that the data in the database is
not always the same length.
Apr 6 '06 #1
4 2464
DWS
Just an idea clickon
Trim the data in sql.
http://msdn2.microsoft.com/en-us/library/ms139947.aspx
select trim(name) from books

Good Luck
DWS
"clickon" wrote:
I am building up the validation expression for a RegularExpresio nValidator
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|10 5$ 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
spaces at the end which builds a string like ^102 |103 |104
|104 |$ which doesn't seem to work for the validation expression.
How do i remove the extraneus white space from the end of data before adding
it to the string variable. Bearing in mind that the data in the database is
not always the same length.

Apr 6 '06 #2
Unfortunately TRIM doesn't apear to be a TSQL function. At least it doesn't
work with SQL 2000, it just returns a "no such funtion as TRIM exception.

"DWS" wrote:
Just an idea clickon
Trim the data in sql.
http://msdn2.microsoft.com/en-us/library/ms139947.aspx
select trim(name) from books

Good Luck
DWS
"clickon" wrote:
I am building up the validation expression for a RegularExpresio nValidator
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|10 5$ 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
spaces at the end which builds a string like ^102 |103 |104
|104 |$ which doesn't seem to work for the validation expression.
How do i remove the extraneus white space from the end of data before adding
it to the string variable. Bearing in mind that the data in the database is
not always the same length.

Apr 6 '06 #3
Hi,

Once you've got the string from your DataTable, you can remove any
white space from the beginning and end using the Trim() method, e.g.:

regExp += "|" + myString.Trim() ; // use a StringBuilder instead ;)

For more info on Trim(), see MSDN:
http://msdn2.microsoft.com/en-US/lib...s3(VS.80).aspx

Hope that helps,

Chris

Apr 6 '06 #4
Try RTRIM(str), this returns a string after removing all trailing
blanks.

SQL Server Books Online:
http://msdn.microsoft.com/library/de...ra-rz_6xm5.asp

Apr 6 '06 #5

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

Similar topics

2
2246
by: Malcolm Dew-Jones | last post by:
I am looking at xslt 1.0 and trying to understand if empty text nodes are supposed to be stripped or not as the default behaviour. 3.4 starts by listing rules for when white space is not stripped and then says "Otherwise the text node is stripped". which appears to contradict a later paragraph that discusses the details of the selection of nodes to be stripped ("Initially ... preserve ... all element names").
5
13124
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...
0
15191
by: Mark Moore | last post by:
I'm trying to layout a couple text input fields and their corresponding labels without using a table. When I was trying to debug my understanding of CSS, I was *very* surprised to see that span's with borders behave counter-intuitively (IMHO) when using style="white-space: nowrap;". Below is a fairly small chunk of XHTML that demonstrates what I'm talking about. What gives? -Mark
8
14275
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...
3
17946
by: Rad | last post by:
I have a table . It has a nullable column called AccountNumber, which is of varchar type. The AccountNumber is alpha-numeric. I want to take data from this table and process it for my application. Before doing that I would like to filter out duplicate AccountNumbers. I get most of the duplicates filtered out by using this query: select * from customers where AccountNumber NOT IN (select AccountNumber from customers where AccountNumber...
2
1972
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!
11
15019
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 -
3
19633
by: Julie | last post by:
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?
2
6638
by: shagy | last post by:
Hi, I'm having a problem with a <select><option> which has white space in values... When I post the data I only get the first word (up to the white space). "Testing white space" becomes "Testing" after posting code... <select name="descr" id="descr">
0
9619
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
9454
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,...
0
10103
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...
0
9911
tracyyun
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...
1
7460
isladogs
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...
0
5354
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...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
2850
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.