How do I split between numbers and characters with regex? -
i have string containing on weekdays , opening hours, how split these lines using regex expression? example of string is:
mån - tor6:30 - 22:00fre6:30 - 20:00lör9:00 - 18:00sön10:00 - 19:00
i want split between lower letter , number, , between number , 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!
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);
Comments
Post a Comment