Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove chars into a string?

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 ?

like image 215
bahamut100 Avatar asked Jul 13 '11 07:07

bahamut100


People also ask

How do I remove the alphabet from a string in Python?

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.

How do I remove a character from a string in Java?

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.

How do I remove a string from a string in Python?

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.


1 Answers

just type cast will do it efficiently

echo (int) $var;
like image 156
Shakti Singh Avatar answered Sep 28 '22 02:09

Shakti Singh