如果为0,则从字符串中删除第一个字符 [英] Remove first character from string if 0

查看:68
本文介绍了如果为0,则从字符串中删除第一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的UITextfield是0,则需要删除它的第一个字符.

I need to remove the first character from my UITextfield if it's a 0.

不幸的是,我不知道如何提取第一个字符的值或如何提取第一个字符之后的字符串的字符.

Unfortunately I don't know how to extract the value of the first character or extract the characters of the string after the first character.

谢谢

推荐答案

一种解决方案可能是:

if ([string hasPrefix:@"0"] && [string length] > 1) {
    string = [string substringFromIndex:1];
}

这篇关于如果为0,则从字符串中删除第一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆