how to remove characters from NSString after specific NSString

前端 未结 2 1858

I am having a string as follows

NSString str1 = @\"Hello your bal = 68094\";

and I want to remove all characters after \"=\" s

2条回答
  •  名媛妹妹
    2021-02-05 07:12

    Maybe not the best solution, but here it is:

    NSString *str1=@"Hello your bal = 68094";
    NSArray *tempArray = [str1 componentsSeparatedByString:@"="];
    str1 = [tempArray objectAtIndex:0];
    NSLog(@"%@", str1);
    

    Output:

    2012-03-15 11:21:01.249 TestApp[1539:207] Hello your bal 
    

    Hope it helps

提交回复
热议问题