Created
June 28, 2014 08:51
-
-
Save jcavar/fb1031e77f567d3babcf to your computer and use it in GitHub Desktop.
Regex to insert \n after every character in string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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