EmEditor (text editor) Forum Index
   Questions and Answers about EmEditor Core
     extract text
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
Stefan
Posted on: 5/2/2012 2:36 am
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 285
Re: extract text
Delete Lines NOT containing STRING

#language = "VBScript"

FileText = document.selection.Text
If FileText = "" Then
	alert "Nothing selected?" & vbCRLF _
	& "This script works with selected text only."
	Quit
End If

PromptText = "Remove lines containing this search string"
searchStr = prompt(PromptText, "")
If searchStr = "" Then Quit

Lines = Split(fileText, vbCRLF)
For each line in Lines
	funcRegEx searchStr, line
        '//FALSE = line not contains search pattern
        '//TRUE  = line contains the search pattern
	If funcRegExReturn = FALSE Then 
	    resultText = resultText + line + vbCRLF
	End If
Next

'editor.NewFile()
document.writeln(resultText)

Function funcRegEx(needle, haystack)
	funcRegExReturn = FALSE
	Set regEx = New RegExp
	regEx.Pattern = needle
	regEx.IgnoreCase = True
	regEx.Global = True
	If regEx.Test(haystack) Then 
           funcRegExReturn = TRUE
        End If
End Function
Flat Previous Topic | Next Topic


Subject Poster Date
   extract text user 5/2/2012 1:04 am
   » Re: extract text Stefan 5/2/2012 2:36 am
       Re: extract text user 5/2/2012 3:33 am
         Macro Delete Lines NOT containing STRING RegEx Pattern Stefan 5/2/2012 10:36 am
           Delete Lines NOT containing STRING RegEx Pattern Bookmark Stefan 5/2/2012 11:10 am
           Re: Macro Delete Lines NOT containing STRING RegEx Pattern user 5/3/2012 7:07 am
             Re: Macro Delete Lines NOT containing STRING RegEx Pattern user 6/4/2012 1:37 am

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文