■ QGREP ■

133 にジャンプ
No. 128 題名 : マッチした場所に文字列を出力 投稿者 : さと
No. 129 題名 : Re:マッチした場所に文字列を出力 投稿者 : CINEPHILE
No. 130 題名 : Re^2:マッチした場所に文字列を出力 投稿者 : さと
No. 131 題名 : Re^3:マッチした場所に文字列を出力 投稿者 : CINEPHILE
No. 132 題名 : Re^3:マッチした場所に文字列を出力 投稿者 : CINEPHILE
No. 133 (130へのコメント)投稿者: CINEPHILE日付: 2003/01/23 18:36:07
題名 : Re^3:マッチした場所に文字列を出力

 一応こんなの作ってみましたが、どうでしょうか?



'QGREPの検索語の直前に文字列を挿入

#comment
・QGREP.INIから自動的に最新の履歴を取得するので、検索終了後、検索結果
  をQXで開いた状態で実行する。
・2行連結には対応していない。
#comment

const c$ = "◎"  '挿入する文字列

proc main
	dim ini$,case,regexp
	dim s$,ss$,item$[10],i,case_sensitive,line,byte,top
	if @hwnd = 0 then exit proc
	'QGREPをQXと別のディレクトリにインストールしている場合は
	'QGREP.INIをフルパスで指定する。(例)ini$ = "C:\QGREP\QGREP.INI"
	ini$ = @@QxDirectory$+"\QGREP.INI"
	if dir$(ini$) = "" then
		call msgbox("QGREP.INIがありません。",MB_ICONINFORMATION)
		exit proc
	end if
	s$ = getprofile$("search","string0",ini$)  '最新の検索履歴を取得
	if s$ = "" then
		call msgbox("履歴がありません。",MB_ICONINFORMATION)
		exit proc
	end if
	case = val(getprofile$("search","Case",ini$))
	regexp = val(getprofile$("search","Regular",ini$))
	i = 1
	do while s$ <> ""
		if instr(s$," ") = 0 then
			ss$ = s$
			s$ = ""
		else
			ss$ = left$(s$,instr(s$," ")-1)
			s$ = mid$(s$,instr(s$," ")+1)
		end if
		if ss$ <> "and" and ss$ <> "or" and ss$ <> "not" \
				and ss$ <> "(" and ss$ <> ")" then
			item$[i++] = ss$
		end if
	loop
	@@ReplaceStringMulti
	case_sensitive = @@FindCaseSensitive
	if case = 0 then
		@@FindCaseSensitive = 1
	else
		@@FindCaseSensitive = 0
	end if
	i = 1
	if regexp = 1 then
		@@FindRegExp = 1:@@FindRegExp = -2
		do while item$[i] <> ""
			@@ReplaceStringMulti "\("+item$[i]+"\)",c$+"\1"
			i++
		loop
	else
		do while item$[i] <> ""
			@@ReplaceStringMulti item$[i],c$+item$[i]
			i++
		loop
	end if
	@Redraw = 0:@UndoBlock = 1
	line = @Line:byte = @BytePos:top = @TopLine
	@MoveFileTop  'ファイルの先頭から実行
	@ReplaceStringMultiExec 1
	@Line = line:@BytePos = byte:@TopLine = top
	@Redraw = 1:@UndoBlock = 0
	@@FindCaseSensitive = case_sensitive
end proc

No. 134 題名 : Re^4:マッチした場所に文字列を出力 投稿者 : さと

全テキストを表示
順番に表示(No. 133 から)


メールアドレスを表示するにはURLの後ろに &m=6947ef7c をつけてください。
フォーラム一覧

http://www2k.biglobe.ne.jp/~araken/
http://0ban.com/araken/