我的列有多个值,如A0045,A00065。我想转换它9945,9965。 需要删除所有0和字符值并在该值之前添加99 ..请帮助..
答案 0 :(得分:0)
这可以通过多种方式完成。这是一种方式(可能不是最好的)。由于我没有数据库,因此我创建了临时表。
def temp-table tt
field val as char.
create tt.
tt.val = "A0045".
create tt.
tt.val = "A00065".
for each tt:
run filter_zero(input-output val).
val = replace(val,"A","99").
DISP val.
end.
procedure filter_zero:
define input-output parameter val as character.
// remvoe all zeroes
repeat while val matches("*0*"):
val = replace(val,"0","").
end.
end procedure.
答案 1 :(得分:0)
下面的代码也删除了大写字母(A-Z)和小写字母(a-z)以及“0”:
DEF TEMP-TABLE test
FIELD str1 AS CHAR.
DEF VAR newStr AS CHAR NO-UNDO.
DEF VAR i AS INT NO-UNDO.
CREATE test.
ASSIGN test.str1 = "A0045".
CREATE test.
ASSIGN test.str1 = "A00065".
FOR EACH test:
DO i = 65 TO 90: /* A - Z */
IF SUBSTR(test.str1, 1, 1) EQ CHR(i) THEN
DO:
test.str1 = REPLACE(test.str1, CHR(i), "").
END.
END.
DO i = 97 TO 122: /* a - z */
IF SUBSTR(test.str1, 1, 1) EQ CHR(i) THEN
DO:
test.str1 = REPLACE(test.str1, CHR(i), "").
END.
END.
/* Removes all 0 and add 99 before the value */
test.str1 = REPLACE(test.str1, "0", "").
ASSIGN test.str1 = "99" + test.str1.
DISP test.
END.
答案 2 :(得分:0)
将变量单词定义为字符no-undo。
将变量i定义为整数no-undo。
指定word =" A00065"。
/ *******删除所有零******** /
word = replace(word,substring(word,index(word," 0"),(r-index(word," 0") - 1)),&# 34;"。)
我= 65到90: 如果substring(word,1,1)= chr(i)那么 做:
word = replace(word,substring(word,1,1),"99").
leave.
端。
端。
显示字词。
答案 3 :(得分:0)
public class UriAttribute: ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
Uri uri;
bool valid = Uri.TryCreate(Convert.ToString(value), UriKind.Absolute, out uri);
if (!valid)
{
return new ValidationResult(ErrorMessage);
}
return ValidationResult.Success;
}
}
答案 4 :(得分:0)
如果这对您有用,请告诉我,未安装Progress因此无法编译和测试。
/ * A0045 - > 9945 A00065 - > 9965 * /
DEFINE VARIABLE v_RawData AS CHARACTER NO-UNDO.
DEFINE VARIABLE v_InpData AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE j AS INTEGER NO-UNDO.
ASSIGN v_RawData = "A0045,A00065".
DO i =1 TO NUM-ENTRIES(v_RawData):
ASSIGN v_InpData = ENTRY(i,v_RawData).
DO j = 1 TO LENGTH(v_InpData):
IF ASC(SUBSTRING(v_InpData,j,1)) > 48 AND
ASC(SUBSTRING(v_InpData,j,1)) < 58 THEN
DO:
LEAVE.
END.
END.
MESSAGE REPLACE(v_InpData,SUBSTRING(v_InpData,1,j - 1),"99").
END.