I have following input:
我有以下输入:
MaintanceGie?\195?\159mannFlock
SupportGie?\195?\159mannFlock
ABCSaskDgfskSblabla
And search for a regex which gives me following result:
并搜索一个正则表达式,它给我以下结果:
Maintance Gie?\195?\159mann Flock
Support Gie?\195?\159mann Flock
ABC Sask Dgfsk Sblabla
For the first both strings I can use following regex ([A-Z]+)([^A-Z]*)
.
What do I have to change to make this regex work?
对于前两个字符串,我可以使用以下正则表达式([A-Z] +)([^ A-Z] *)。为了使这个正则表达式工作,我需要改变什么?
Thanks for any advices.
谢谢你的任何建议。
3 个解决方案
#2
1
Here is a way to do it in Perl:
以下是在Perl中执行此操作的方法:
#!/usr/bin/perl
use strict;
use warnings;
use 5.10.1;
while(<DATA>) {
chomp;
s/(.)([A-Z][^A-Z])/$1 $2/g;
say $_;
}
__DATA__
MaintanceGie?\195?\159mannFlock
SupportGie?\195?\159mannFlock
ABCSaskDgfskSblabla
output:
Maintance Gie?\195?\159mann Flock
Support Gie?\195?\159mann Flock
ABC Sask Dgfsk Sblabla
#3
0
([A-Z](?=[^A-Z]))
This will find any uppercase letter followed by lowercase
这将找到任何大写字母后跟小写
#1
#2
1
Here is a way to do it in Perl:
以下是在Perl中执行此操作的方法:
#!/usr/bin/perl
use strict;
use warnings;
use 5.10.1;
while(<DATA>) {
chomp;
s/(.)([A-Z][^A-Z])/$1 $2/g;
say $_;
}
__DATA__
MaintanceGie?\195?\159mannFlock
SupportGie?\195?\159mannFlock
ABCSaskDgfskSblabla
output:
Maintance Gie?\195?\159mann Flock
Support Gie?\195?\159mann Flock
ABC Sask Dgfsk Sblabla
#3
0
([A-Z](?=[^A-Z]))
This will find any uppercase letter followed by lowercase
这将找到任何大写字母后跟小写