?
Solved

Remove last characters of a string

Posted on 2007-11-30
4
Medium Priority
?
2,719 Views
Last Modified: 2012-06-27
hi all,

I have a URL that I need to change.

It looks like this:

http://www.somewebsite/com/35445485448154_2b.jpg

I need to remove the "2b.jpg" at the end and replace it with "1b.jpg"

It's urgent...could you please help?

Thanks

ST3VO
0
Comment
Question by:ST3VO
[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
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 2000 total points
ID: 20381124
if its' something else you're looking for, give more details.
function update_url(url, s:string):string;
var i:integer;
begin
  i:=pos('_', url);
  assert(i>0);
  delete(url, i+1, length(url));
  result:=url+s;
end;
 
....
update_url('http://www.somewebsite/com/35445485448154_2b.jpg', '1b.jpg');
....

Open in new window

0
 

Author Comment

by:ST3VO
ID: 20381173
Why isn't this working??? Edit box it now being updated!
function update_url(url, s:string):string;
var i:integer;
begin
  i:=pos('_', url);
  assert(i>0);
  delete(url, i+1, length(url));
  result:=url+s;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var s, new: string;
begin
s:=Edit1.Text;
update_url(s,'1b.jpg');
Edit1.Text:=(s);
 
end;

Open in new window

0
 
LVL 28

Expert Comment

by:2266180
ID: 20381201
update_url is a funciton not a procedure. which means it returns the modified string as a result. basically this allows you to use it nicely in one line like below ;)
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text:=update_url(edit2.text,'1b.jpg');
end;

Open in new window

0
 

Author Closing Comment

by:ST3VO
ID: 31411890
Perfect!!! Thanks! :o)
0

Featured Post

Technology Partners: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

741 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