Re: 文字列内の文字を置換する文字列は同じパターンに従っているように見えます。 区切り文字としてスペースまたは " を使用して、words() 関数を使用することもできます。 次に、 concatitems() を使用して元に戻します。

Re: 文字列内の文字を置換する正規表現はもう 1 つのオプションです
Regex(:Results, "(BIN = \!".+\!") (\d+)(\!".+)", "\1 " || Char(:Count) || "\3")
ただし、この場合、Craigeが提案したように Words() + Concat Items() を使用します(パターンが常に同じ場合)
Re: 文字列内の文字を置換するクレイグとジャーモ、ありがとう
Re: 文字列内の文字を置換する問題はこの行にあると思います
x[4] = Char( arra[binxx[j]] );
連想配列 + 行ではなく、行をループするようにループを変更します。
Names Default To Here(1);
dt = Current Data Table();
/// Get list of all the bins
binxx = Associative Array(:Bins[23 :: N Rows(dt)]) << Get Keys;
delcols = {"", " ", "}"};
/// Remove garbage values
For(i = 1, i <= N Items(delcols), i++,
Remove From(binxx, As List(Loc(binxx, delcols[i])));
);
///Get rows where Bins column contains BIN =
rows = dt << get rows where(Contains(:Bins, "BIN = "));
total = {};
//Loop to calculate the count of each bins
For(i = 1, i <= N Items(binxx), i++,
Insert Into(total, N Items(dt << get rows where(:Bins == binxx[i])))
);
//create array to store bin and counts
arra = Associative Array(binxx, total);
//loop to modify the character count in the table
For(i = 1, i <= N Items(rows), i++,
x = Words(:Bins[rows[i]]);
curbin = Substitute(x[3], "\!"", "");
If(Contains(arra, curbin),
x[4] = Char(arra[curbin]);
:Bins[rows[i]] = Concat Items(x);
,
continue();
);
);Re: 文字列内の文字を置換するありがとう、ジャーモ
Re: 文字列内の文字を置換する@jthi
Cragis ロジックを使用して文字列内のカウントを更新しましたが、正しいカウント文字列は置き換えられません。 何が間違っているのかわかりません。 私のコードを見てもらえますか?
間違ったカウントを割り当てる
コードは次のとおりです。
dt = Current Data Table();
/// Get list of all the bins
binxx = Associative Array( :Bins[23:: N Rows( dt )] ) << Get Keys;
delcols = {"", " ", "}"};
/// Remove garbage values
For( i = 1, i <= N Items( delcols ), i++,
Remove From( binxx, As List( Loc( binxx, delcols[i] ) ) );
);
///Get rows where Bins column contains BIN =
rows = dt << get rows where( Contains( :Bins, "BIN = " ) );
total = {};
//Loop to calculate the count of each bins
For( i = 1, i <= N Items( binxx ), i++,
Insert Into( total, N Items( dt << get rows where( :Bins == binxx[i] ) ) )
);
//create array to store bin and counts
arra = Associative Array( binxx, total );
//loop to modify the character count in the table
For( j = 1, j <= N Items( binxx ), j++,
For( i = 2, i <= N Items( rows ), i++,
If( Contains( arra, Substr( :Bins[i], 8, 1 ) ),
x = Words( :Bins[rows[i]] );
x[4] = Char( arra[binxx[j]] );
:Bins[rows[i]] = Concat Items( x );
)
)
);
文字列内の文字を置換するこんにちは、JMP コミュニティです。
文字列を含む列を取得し、各行でカウントをカウント列の値に置き換える JSL コードを作成しようとしています。 最終的な結果は、「結果」列のようになります。
助言がありますか?
自動化とスクリプト作成