Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trimming a string help

Status
Not open for further replies.

EchoAlertcom

IS-IT--Management
Oct 8, 2002
239
US
Hello,

I need help trimming this string.
Code:
strIPAddress = "Pinging widgets.com [132.53.184.107] with 32 bytes of data:"

I want only: strResults = "132.53.184.107"

Thank you for the quick responses as always.

Sincerely,
Steve Funk
 
if you know the strings contents then the use of the Left() and Right() Functions should be all you need.
Left(string, length)
var = "string"
var2 = Left(var, 3)
'output = str A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
let me rephrase this.

in the string i gave in my first post.

I want to remove everything up to AND including the [
i then want to remove everything that is past AND including the ]

ie.
Code:
strIPAddress = "Pinging widgets.com [132.53.184.107] with 32 bytes of data:"

becomes

Code:
strResults = "132.53.184.107"

The [ and ] will always contain exactly what i want even thought what is between them changes in length.

I hope this is more explicit.

Thank you for your help

Sincerely,
Steve Funk
 
let me rephrase this.

in the string i gave in my first post.

I want to remove everything up to AND including the [
i then want to remove everything that is past AND including the ]

ie.
Code:
strIPAddress = "Pinging widgets.com [132.53.184.107] with 32 bytes of data:"

becomes

Code:
strResults = "132.53.184.107"

The [ and ] will always contain exactly what i want even thought what is between them changes in length.

I hope this is more explicit.

Thank you for your help

Sincerely,
Steve Funk
 
strIPAddress = "Pinging widgets.com [132.53.184.107] with 32 bytes of data:"
strLeftRight = Right(Left(strIPAddress,35),14) A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Or, if the first part of your string changes, use the instr() function:

strIPAddress = "Pinging widgets.com [132.53.184.107] with 32 bytes of data:"
strIPAddress = mid(strIPAddress,instr(strIPAddress,"[")+1,len(strIPAddress))
strIPAddress = left(strIPAddress,instr(strIPAddress,"]")-1)
Response.write strIPAddress

Hope that helps...
mwa
 
hence my remark
if you know the strings contents
which was never really stated clear

just a reminder to everything that the most detailed question is the best and easiest for everyone to help with. A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Onpnt... I caught that, I was just giving how do this, if you don't know the strings contents.

And yes, giving all of the detail available is always most helpful...

mwa
 
Sorry if I sounded rude. just had a minute of frustration. [thumbsup2] A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top