C# - String.Remove Ex.
int j = 4;
string pages = "/.././ewcwe/";
pages = pages.Remove(j, 2);
// pages = "/../ewcwe/";
// delete ./
Is there such a function in python string.remove?
sorry, **./** -> ./
C# - String.Remove Ex.
int j = 4;
string pages = "/.././ewcwe/";
pages = pages.Remove(j, 2);
// pages = "/../ewcwe/";
// delete ./
Is there such a function in python string.remove?
sorry, **./** -> ./
Strings are immutable, so you need to extract the parts you want and create a new string from them:
s = pages[:4] + pages[10:]
Alternatively you can overwrite the existing string (as pointed out in the comment below):
pages = pages[:4] + pages[10:]
You can write your own metod.
>>>s="vivek"
>>> def rep(s,st,ed):
... return s[:st]+s[ed:]
...
>>> rep(s,2,3)
'viv'
No strings don't have such a method
However if you use a bytearray it's easy to remove a slice
pages = bytearray(pages)
del pages[4:10]
Possibly what you are trying to achieve could be done better with a regular expression
Simply No
need to use Regular Expressions for faster performance