Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delete characters after a whitespace

Posted on 2007-03-18
4
Medium Priority
?
397 Views
Last Modified: 2013-11-26
I need to be able to delete characters after a whitespace in a string. This is so I can get the first part of a postal code. For example, I want to convert the psotcode NW3 4DD to just NW3 etc. Is there a way to do this with Regex or in vb.net?

Seb
0
Comment
Question by:sebastiz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 18743129
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=169&lngWId=10

postcode = yourdata.SubString(1, yourdata.IndexOf(" "))
0
 
LVL 34

Expert Comment

by:Sancler
ID: 18743267
.Substring works with a zero-based, not a one-based index.  That should be

   postcode = yourdata.SubString(0, yourdata.IndexOf(" "))

Roger
0
 

Author Comment

by:sebastiz
ID: 18743295
This is what Ive got, but doesnt seem to be working:

 dt.Columns("Regex Postcode").Expression = "substring(pcode, 0,4)"
pcode has ben defined in the SQL statement
0
 

Author Comment

by:sebastiz
ID: 18743318
I sorted it- it is a 1 based index, not zero, which is where my error was.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question