How do I split between numbers and characters with regex?

I have a string containing on weekdays and opening hours, how do I split these into lines using a regex expression? An example of a string is:

Mån - Tor6:30 - 22:00Fre6:30 - 20:00Lör9:00 - 18:00Sön10:00 - 19:00

I want to split between a lower letter and a number, and between a number and a capital letter

Mån - Tor  
6:30 - 22:00  
Fre  
6:30 - 20:00  
Lör  
9:00 - 18:00  
Sön  
10:00 - 19:00 

Thanks in advance!

Answers


Split on

(?<=\d)(?=\p{L})|(?<=\p{L})(?=\d)

For example, in C#:

splitArray = Regex.Split(subjectString, @"(?<=\d)(?=\p{L})|(?<=\p{L})(?=\d)");

or in PHP:

$result = preg_split('/(?<=\d)(?=\p{L})|(?<=\p{L})(?=\d)/u', $subject);

or in Java:

String[] splitArray = subjectString.split("(?<=\\d)(?=\\p{L})|(?<=\\p{L})(?=\\d)");

or in Perl:

@result = split(m/(?<=\d)(?=\p{L})|(?<=\p{L})(?=\d)/, $subject);

Need Your Help

How do I hide the strings being sent to the client?

jquery asp.net ajax http

I have a csv file on the server side which is retrieved by the client with a jquery ajax call.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.