?
Solved

Delete characters after a whitespace

Posted on 2007-03-18
4
Medium Priority
?
396 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 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