473,414 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Removing X number of characters starting at begining or end

Eh, probably not the most specific subject line...

But, I've got a number of fields in which I need to do things like remove
the first 4 characters, or remove the last 3.

Such as:

F300006745

Remove first 4 to leave

006745

or remove the last 3 to leave

F3000067

Is there a generic type script I can use to accomplish both of these by
changing a few parameters? Or would it require 2 distinctly seperate ones
for each operation?

Thanks.
Nov 13 '05 #1
4 64326
To remove first 4 characters:
Mid([MyField],5,Len([MyField]))

To exclude the last 3 characters:
Mid([MyField],1,Len([MyField])-3))

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Adam" <ad**@firstmanmedia.com> wrote in message
news:95*******************@204.127.204.17...
Eh, probably not the most specific subject line...

But, I've got a number of fields in which I need to do things like remove
the first 4 characters, or remove the last 3.

Such as:

F300006745

Remove first 4 to leave

006745

or remove the last 3 to leave

F3000067

Is there a generic type script I can use to accomplish both of these by
changing a few parameters? Or would it require 2 distinctly seperate ones
for each operation?

Thanks.

Nov 13 '05 #2
Adam wrote:
Eh, probably not the most specific subject line...

But, I've got a number of fields in which I need to do things like remove
the first 4 characters, or remove the last 3.

Such as:

F300006745

Remove first 4 to leave

006745

or remove the last 3 to leave

F3000067

Is there a generic type script I can use to accomplish both of these by
changing a few parameters? Or would it require 2 distinctly seperate ones
for each operation?

Thanks.


Two distinct are Left() and Right() but you'll probably get away with
just the one, mid()

Remove first 4:
NewString = Right(OldString,Len(OldString)-4)
or
NewString = Mid(OldString,5)

Remove last 4
NewString = Left(OldString,Len(OldString)-4)
or
NewString = Mid(OldString,1,Len(OldString)-4)

--
This sig left intentionally blank
Nov 13 '05 #3
Great!

One more real quick.

How about to remove everything in the string except X number of characters
starting at position Y. For example, to keep only the 3 characters
starting at position 8?

So this:

F1053630203XL1

Becomes

020

Thanks!

no****@nospam.spam (PC Datasheet) wrote in
<tX******************@newsread2.news.atl.earthlink .net>:
To remove first 4 characters:
Mid([MyField],5,Len([MyField]))

To exclude the last 3 characters:
Mid([MyField],1,Len([MyField])-3))

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Adam" <ad**@firstmanmedia.com> wrote in message
news:95*******************@204.127.204.17...
Eh, probably not the most specific subject line...

But, I've got a number of fields in which I need to do things like
remove the first 4 characters, or remove the last 3.

Such as:

F300006745

Remove first 4 to leave

006745

or remove the last 3 to leave

F3000067

Is there a generic type script I can use to accomplish both of these
by changing a few parameters? Or would it require 2 distinctly
seperate ones for each operation?

Thanks.



Nov 13 '05 #4
Ooops, never mind:

Mid([fieldname],8,3)

ad**@firstmanmedia.com (Adam) wrote in
<95*******************@204.127.199.17>:
Great!

One more real quick.

How about to remove everything in the string except X number of
characters starting at position Y. For example, to keep only the 3
characters starting at position 8?

So this:

F1053630203XL1

Becomes

020

Thanks!
F3000067

Is there a generic type script I can use to accomplish both of these
by changing a few parameters? Or would it require 2 distinctly
seperate ones for each operation?

Thanks.




Nov 13 '05 #5

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

Similar topics

2
by: Amit Varia | last post by:
How would you remove newline characters from a string? I tried str_replace("\n", "", $string); But that doesn't work.
3
by: mr_burns | last post by:
Hi there, How do I remove space characters from a string using PHP? For example, the following string... ' hi there, my name is burnsy ' ....has spaces, at the edges and inbetween the...
2
by: matt | last post by:
I have an upload script for a photo and a caption. It all goes pear shaped when I upload a character like ' " or / \ | Is there anyway I can parse through the filename when submitting the form and...
2
by: Abby Lee | last post by:
I need to add and subtract transactions for each of our accounts within our Access DB for account reconciliation. Values found in our PdAmount field are either positive or negative. Positive...
1
by: Phil Amey | last post by:
In a web based form I am able to make sure that there is text in an input field but I want to restrict the user from using such characters as ~ # & ' How can I modify this JavaScript below to...
0
by: David Lambert | last post by:
Hi, I have a text reader that is parsing a file, I have a number of lines with accents eg. "Herr Dietman Löflers (CEO)" my text reader returns: "Herr Dietman Lflers (CEO)", it drops all the...
8
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...
2
by: Renuka | last post by:
Hello, I have to retrive 2 columns from the database which have HTML characters like &lt; &gt; (the less than"<" and greater than sign ">")in their data. Is there any function in C# which can do...
0
by: Benny the Guard | last post by:
I have a string value that may contain some unprintable characters. I am using the xml.sax.escape to remove the the <, > and & characters fine but it seems to leave in the \n characters. Later this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
Oralloy
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,...
0
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...
0
agi2029
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,...
0
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...

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.