Find strings with a regular expression and output them to new file

Help with writing and running scripts

Find strings with a regular expression and output them to new file

Postby Mofi » Sat Sep 29, 2012 11:53 am

On IDM extra downloads page there is in Scripts section the scripts collection Find strings to new file created by me to ask the script user on execution for a regular expression search string to find strings of interest in active file and output all found strings in a new file line by line.

The scripts can be used on small files as well as on files with several MB or even GB and is very fast as it does anything in memory.

Note: The regular expression string to enter must be of Perl syntax and is applied to a Javascript RegExp object which is not as powerful as the Perl regular expression engine within UltraEdit.

The search is executed not case sensitive as of option gi which means global case-insensitive.

For example to find and output to a new file all integer numbers within a file execute the script and enter \d+

Read also FindStringsReadMe.txt within the ZIP archive and the comments at top of the script file you want to use.

The ZIP file contains following scripts:

  • FindStringsToNewFile.js
    searches in entire active file for strings with a regular expression and outputs only all found strings line by line to a new file. It can be used for small files with some KiB and larger files up to a few MiB.
  • FindStringsToNewFileExtended.js
    is like FindStringsToNewFile.js with the difference that it can be used also for really large files with many MiB or even GiB. This script cannot be used with UE v13.00 and UES v6.20.
  • FindStringsWithLineNumbers.js
    is like FindStringsToNewFile.js with the difference that line number information is also output on every line with a found string in the new file. This script can be used for small files with some KiB and larger files up to a few MiB.
  • FindStringsWithLineNumbersExtended.js
    is like FindStringsWithLineNumbers.js with the difference that it can be used also for really large files with many MiB or even GiB. This script cannot be used with UE v13.00 and UES v6.20.

Post a reply here if you have questions regarding this script or suggestions for improving the script.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Find strings with a regular expression and output them to new file

Postby Mofi » Mon Oct 22, 2012 12:13 pm

The original script FindStringsToNewFile.js has been improved and 3 new scripts have been added on 2012-10-07, see updated first post. The ZIP file contains now also a ReadMe file (updated today) for this collection of scripts.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Scripts