如何仅从字符串开头删除点

How to remove dots only from starting of string

我的字符串文本就像 -

1) .....bla ..bla...
2)...bla.. bla…bla.
3).bla.. bla…bla.

点不是 static.I 只想从开始删除点。不是所有的点

我试过这个

NSString *newString = [myString stringByReplacingOccurrencesOfString:@"." withString:@""];

但这是删除所有点。

试试这个。

NSString* regex = @"^\.*";
NSString* input = @"....abc..z";
NSString* output = [input stringByReplacingOccurrencesOfString:regex withString:@"" options:NSRegularExpressionSearch range: [input rangeOfString:input]];
var test = "...abc";

while test.hasPrefix(".") {
    test.remove(at: test.startIndex)
}
//test variable will have dots removed at the start.

试试这个。

试试这个:

NSString *str = @"...Videt...IDL";

__block NSInteger loc = 0;
[str enumerateSubstringsInRange:NSMakeRange(0, str.length) options:NSStringEnumerationByWords usingBlock:^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) {
    loc = substringRange.location;
    *stop = YES;
}];

NSString *convStr = [str substringFromIndex:loc];
NSLog(@"%@", convStr);
NSString *str = @"....bla .... bla..... bla";
    NSCharacterSet *charSet = [NSCharacterSet letterCharacterSet];
    int letterNO = 0;
    for (int i =0; i<str.length; i++)
    {
        NSString *letter = [NSString stringWithFormat:@"%c",[str characterAtIndex:i]];
        if ([letter rangeOfCharacterFromSet:charSet].location != NSNotFound)
        {
            letterNO = i;
            break;
        }
    }
    NSString * newString = [str substringFromIndex:letterNO];
    NSLog(@"newString %@",newString);