テキストから数字を含む文字列を削除するこんにちは、
これは、JSL を使用して数字を含む文字列を削除する方法ですか?
例:
リンゴ4個とバナナ2本を食べました
モデル番号は0998GBELSです
03/45はチェックする比率です
ターゲット出力:
リンゴとバナナを食べました
モデル番号は
チェックする比率は
自動化とスクリプトRe: テキストから数字を含む文字列を削除するこれがすべての状況で機能するかどうかはわかりませんが、これらの例では機能します
Names Default To Here(1);
strs = {
"I ate 4 apples and 2 bananas",
"the model number is 0998GBELS",
"03/45 is the ratio to check"
};
result2 = Transform Each({str}, strs,
Regex(str, "\w*\S*\d+\w*\S*", "", GLOBALREPLACE)
);
show(result2); // result2 = {"I ate apples and bananas", "the model number is ", " is the ratio to check"};
編集:
正規表現を少し簡略化して
Regex(str, "\S*\d+\S*", "", GLOBALREPLACE)
https://regex101.com/r/PM4UQn/1
Re: テキストから数字を含む文字列を削除する処理する行が多数(数億行)あるため、処理するとレイテンシが高くなります。レイテンシを抑えながら数字を含む文字列を削除するより良い方法はあるでしょうか?
Re: テキストから数字を含む文字列を削除するこれは機能しますが、正規表現に精通している人はスクリプトを簡素化することができます。
Names Default To Here( 1 );
theString = "I ate 4 apples and 2 bananas
the model number is 0998GBELS
03/45 is the ratio to check";
theList = Words( theString, " \!n\!r\!t" );
adjustedString = "";
For Each( {member}, theList,
Show( member );
//member=thelist[1]
found = "No";
If( !Contains( member, "0" ),
If( !Contains( member, "1" ),
If( !Contains( member, "2" ),
If( !Contains( member, "3" ),
If( !Contains( member, "4" ),
If( !Contains( member, "5" ),
If( !Contains( member, "6" ),
If( !Contains( member, "7" ),
If( !Contains( member, "8" ),
If( !Contains( member, "9" ),
adjustedString = Trim( adjustedString || " " || member )
)
)
)
)
)
)
)
)
)
);
);
Show( adjusted String );