このデータをコピーすると、次の結果が得られます。
R 1 -9.00
+0.03
G 2 -8.00
+0.36
F 3 -7.00
-0.26
奇数行ごとに3列、。で始まり[A-Z]
、次の行に必要なデータ。
必要な数値には2つの形式があります。
^\t {3}([-+][0-9]+\.[0-9]{2})$ //for the red numbers
と:
^([-+][0-9]+\.[0-9]{2}) {3}\t$ //the green numbers
次のように両方のタイプを抽出できます。
^(\t {3})?([-+][0-9]+\.[0-9]{2})( {3}\t)?$
2番目のキャプチャグループ([-+][0-9]+.[0-9]{2})
は、あなたが求めているコンテンツです。
s/^(\t {3})?([-+][0-9]+\.[0-9]{2})( {3}\t)?$/$2/g
Applescriptの代わりに、BBEditまたはTextwranglerを検討してください。これらは使いやすいと思われるかもしれません。
これを検索フィールドに入力します。
\r[A-Z].*\r(\t {3})?([-+][0-9]+.[0-9]{2})( {3}\t)?$
そしてこれを置き換えます:
\ r \ 2
「すべて置換」を選択します
使い方
\r // carriage return
[A-Z] // any character from A to Z (the lines you DON't want all start with a letter)
. // any character
* // any number of times
\r // carriage return
// that deals with the lines you DON't want to keep
( // grouping
\t // tab character
{3} // space character repeated 3 times
) // close grouping
? // zero or one occurences of the previous grouping
( // grouping (this is the bit you are after)
[+-] // character class - one of any of the [enclosed characters]
[0-9] // one of any of 0-9
+ // repeated one or more times
\. // full stop (escaped as it has special meaning in regext)
[0-9]{2} // exactly two occurences of any of 0-9
) // close capture parens (end of the group you are after)
( {3}\t)? // 3 spaces followed by a tab, occurring 0 or 1 time.
$ // end of line (in BBEdit/textwrangler you often use \r)
BBE / TWの重要な詳細として、キャプチャされたグループは\ 1、\ 2、\ 3と呼ばれ、$ 1、$ 2、$3ではありません…</p>