恭喜,你发布的帖子
发布于 2025-01-18 20:31:09
6楼
再再介绍一种方法:使用FOR循环替换FIND+使用CONTACT替换MID。
1、初始化
REGION initialization
#tempStrSrc := #iStrSrc;
#tempStrFlag := #iStrFlag;
END_REGION
2、使用FOR循环替换FIND
REGION logic
REGION fixFlagsPositions
#tempIntSrcLen := LEN(#tempStrSrc);
FOR #tempDIntSrcStrIndex := #cIntZero TO #tempIntSrcLen DO
IF #tempDIntOrderNumIndex >= #cIntZero AND #tempDIntOrderNumIndex < #cIntThree THEN//execute until find out the third flag
IF #tempStrSrc[#tempDIntSrcStrIndex] = #iStrFlag THEN//find out flag
#ioArrayOrderNum[#tempDIntOrderNumIndex] := #tempDIntOrderNumIndex;//save flag order number
#tempDIntOrderNumIndex := #tempDIntOrderNumIndex + #cIntOne;//self-add
#ioArrayPosition[#tempDIntPosIndex] := #tempDIntSrcStrIndex;//save flag position
#tempDIntPosIndex := #tempDIntPosIndex + #cIntOne;//self-add
END_IF;
ELSE
;
END_IF;
IF #tempDIntOrderNumIndex = #cIntThree THEN
EXIT;
END_IF;
END_FOR;
END_REGION
3、使用CONTACT替换MID
REGION getSubstring
FOR #tempDIntSubstrIndex := #ioArrayPosition[#cIntOne] + #cIntOne TO #ioArrayPosition[#cIntTwo] - #cIntOne DO
#tempStr := '';
#tempStr := #tempStrSrc[#tempDIntSubstrIndex];
#tempStrSubstr := CONCAT(IN1 := #tempStrSubstr, IN2 := #tempStr);
END_FOR;
END_REGION
4、输出
REGION output
#oStrSubstr := #tempStrSubstr;
END_REGION
请填写推广理由:
分享
只看
楼主