我有这样的话:
example1:example2:example3
example1:exa5:exa8
我想将它们转换为
example1:example3
example1:exa8
是否可以使用正则表达式来做到这一点?
任何帮助将不胜感激。
谢谢!
答案 0 :(得分:0)
在查找用途中:
+ (UIImage *) drawRectIntoImage:(UIImage *)image {
cv::Mat mat;
UIImageToMat(image, mat, true);
vector<cv::Point> v;
v.push_back(cv::Point(100,100));
v.push_back(cv::Point(500,0));
v.push_back(cv::Point(500,500));
v.push_back(cv::Point(100,100));
cv::polylines(mat, v, true, cv::Scalar(244, 66, 66, 255), 8);
cvtColor(mat, mat, CV_RGB2RGBA);
cv::fillConvexPoly(mat, v, cv::Scalar(244, 66, 66, 100));
UIImage *binImg = MatToUIImage(mat);
return binImg;
}
替换为空字符串。
表达式:
(?<=:)[a-z0-9]+:
对(?<=:)
的积极期待。:
匹配小写字母和数字。[a-z0-9]+
匹配:
。答案 1 :(得分:0)
:[^:\r\n]+(?=:)
LEAVE EMPTY
说明:
: # a colon
[^:\r\n]+ # 1 or more any character that is not a colon or line break
(?=:) # positive lookahead, make sure we have a colon after
给定示例的结果
example1:example3
example1:exa8