Skip to content

Instantly share code, notes, and snippets.

@jcavar
Created June 28, 2014 08:51
Show Gist options
  • Save jcavar/fb1031e77f567d3babcf to your computer and use it in GitHub Desktop.
Save jcavar/fb1031e77f567d3babcf to your computer and use it in GitHub Desktop.
Regex to insert \n after every character in string
NSString *horizontalText = @"horizontal text";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(.)" options:NSRegularExpressionCaseInsensitive error:nil];
NSString *verticalText = [regex stringByReplacingMatchesInString:horizontalText options:0 range:NSMakeRange(0, horizontalText.length) withTemplate:@"$1\n"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment