- May 2, 2012 at 9:04 am #10301
my goal is to extract specific text from a text file
I search for a specific regex, I want to select all the matches of this regex, then I want to reverse selection and delete that selection, so that only the regex matches will be left
can you tell me please how to do this (particularly the “select all” and “reverse selection” parts) or a better way to do it
thanks!May 2, 2012 at 10:36 am #10302
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."
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
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 FunctionMay 2, 2012 at 11:33 am #10303
thanks but how do I use this?
I save it as .vbs file and load it as macro
thanksMay 2, 2012 at 6:36 pm #10305
user> what’s next?
* Save this script/macro to an text file with VBS or VBEE extension.
(please save it again, i have edited an comment failure in the meantime)
* Macros > Select this (means the current open macro file)
* Macros > Select… >>> choose the macro
* Open your text file to edit.
* Select an paragraph or the whole text (Ctrl+a)
* Execute the macro: Macros > Run myMacro.vbs
EmEditor Help > EmEditor Macro Reference > Tutorial > Run MacroMay 2, 2012 at 7:10 pm #10306
Note, with last beta
“Head-start version: EmEditor Professional v11.1.6 beta”
you can also use:
* Find: [ pattern ] with [Bookmark all]
* “Invert Bookmarks in This Group”
* “Delete Bookmarked Lines in This Group”May 3, 2012 at 3:07 pm #10309
ok but where do I specify the regex???
> Delete Bookmarked Lines in This Group”
I dont want to delete the bookmarked lines, I want to delete the inverted selection :/June 4, 2012 at 9:37 am #10393
it says that there is an error at line 17, any hint???
You must be logged in to reply to this topic.