I have a lot of strings, and I need to delete '0' at start of string, but what is the better way to do it, because this is an example of strings:
0130799.jpg //I need to get 130799
0025460.jpg //I need to get 25460
Now, I'm using substr function, but I think it's more efficient if I'll use Regex no ?
Python Remove Character from String using replace() We can use string replace() function to replace a character with a new character. If we provide an empty string as the second argument, then the character will get removed from the string.
The idea is to use the deleteCharAt() method of StringBuilder class to remove first and the last character of a string. The deleteCharAt() method accepts a parameter as an index of the character you want to remove.
In Python you can use the replace() and translate() methods to specify which characters you want to remove from a string and return a new modified string result. It is important to remember that the original string will not be altered because strings are immutable.
just type cast will do it efficiently
echo (int) $var;
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