How to delete last character of String with substring
or anything ?
For example;
var
query : String;
begin
query:= 'test=1&line=5&';
end;
Output must be :
query -> test1&line=5
Remove last N characters from string Using negative slicing Last character in string has index -1 and it will keep on decreasing till we reach the start of the string. So to remove last 3 characters from a string select character from 0 i.e. to -3 i.e.
Use the String. slice() method to remove the last 3 characters from a string, e.g. const withoutLast3 = str. slice(0, -3); . The slice method will return a new string that doesn't contain the last 3 characters of the original string.
A third option is this:
SetLength(Query,LENGTH(Query)-1)
Try this:
var
query : String;
begin
query:= 'test=1&line=5&';
delete(query,length(query),1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With