Solved

Remove last characters of a string

Posted on 2007-11-30
4
2,659 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
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 500 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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