mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Added possibility to strip left and right to strip_edges (#4594)
(cherry picked from commit 49c473bb36)
This commit is contained in:
committed by
Rémi Verschelde
parent
6d50ccfd32
commit
c575f31d5d
@@ -2867,25 +2867,29 @@ CharType String::ord_at(int p_idx) const {
|
||||
return operator[](p_idx);
|
||||
}
|
||||
|
||||
String String::strip_edges() const {
|
||||
String String::strip_edges(bool left, bool right) const {
|
||||
|
||||
int len=length();
|
||||
int beg=0,end=len;
|
||||
|
||||
for (int i=0;i<length();i++) {
|
||||
if(left) {
|
||||
for (int i=0;i<len;i++) {
|
||||
|
||||
if (operator[](i)<=32)
|
||||
beg++;
|
||||
else
|
||||
break;
|
||||
if (operator[](i)<=32)
|
||||
beg++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=(int)(length()-1);i>=0;i--) {
|
||||
if(right) {
|
||||
for (int i=(int)(len-1);i>=0;i--) {
|
||||
|
||||
if (operator[](i)<=32)
|
||||
end--;
|
||||
else
|
||||
break;
|
||||
if (operator[](i)<=32)
|
||||
end--;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (beg==0 && end==len)
|
||||
|
||||
Reference in New Issue
Block a user