Following System Variables are supported:
$match the matched text to be replaced
$match the sub-item of the $match, see explanation below
$max the number of sub-item of the $match
$para_no the matched sequence No. of current paragraph
$line_no the matched sequence No. of current line
$word_no the matched sequence No. of current word
$unit_num the total number of replace units(may hold value of total word number, line number or paragraph number).
$global_line_no the global line No., including matched and unmatched lines.
$previous the text followed by the $match
$next the text following the $match
$file_no in multi-file operation, indicate the sequence no of the current processing file.
$FULLNAME the full name of current reading file with path
$DIRNAME the pathname of current reading file
$FILENAME the name of current reading file without path, it's blank if no file is read
$BASE the name of current reading file without path info and extesion
$EXT the extension of current reading file
$URL the url of current loading http address
$FULLNAME_OUT user can change $FULLNAME_OUT at run time, system will save to file $FULLNAME_OUT after processing file content.
$FILENAME_OUT user can change $FILENAME_OUT at run time, system will save to path $FILENAME_OUT after processing file content.
$DIRNAME_OUT user can change $DIRNAME_OUT at run time, system will save to file $DIRNAME_OUT after processing file content.
$batch_no1,$batch_no2,$batch_no3 can be used for make_batch and make_batch1 functions, check Functions part for detail.
Following are variables in 'settings' dialog, user can change it in replace command, system will restore it after each replace operation:
$word_input_delimiter word input delimiter pattern: None=undef, Space=' ', Spaces='[ ]+', Tab='\t'
$word_output_delimiter word output delimiter pattern: None=undef, Space=' ', Spaces='[ ]+', Tab='\t'
$fixed_word_widths fixed number of characters for words
$paragraph_start_line paragraph start line pattern: None=undef, Blank Line='^$', Blank Line With space='^\s*$'
$paragraph_end_line paragraph end line pattern: None=undef, Blank Line='^$', Blank Line With space='^\s*$'
$fixed_para_lines fixed number of lines for paragraphs
$input_encoding reading a file with this type of Encoding
$output_encoding writing a file with this type of Encoding
$split_name the rule of filename spliting
$split_size number of bytes/chars/lines/files to split
$split_type split by Chars, Bytes, Lines or Files
$bak_flag whether make backup before overwriting file
$bak_ext extension of backup file name
$overwrite_confirm whether get user's confirm before overwriting file
$unix_flag whether output as UNIX format
Note: If user do not change run-time values of above parameters, the value will follow the setting page in "Replace Dialog"
Syntax of $match:
$match[start..end] stands for the start to end sub-items of the $match. The sub-item of "paragraph" is "line", the sub-item of "line" is "word", the sub-item of "word/chars" is "char".
If replace unit is "Paragraph", $match[1..3] means lines 1,2,3 of the matched paragraph.
If replace unit is "Line", $match[3,6,4] means words 3,6,4 of the matched line.
If replace unit is "Word", $match[..2,4,3,5..] means chars 1,2,4,3,5,6,7... of the matched word.
Following variables and arrays can be set and used by users, they will be cleared before each replace operation.
variables: $A - $Z
arrays: @a - @z
Pattern Memory variables(supported since version 2.2):
$num or \num or $var[num] (num=1,2,3,...9) This group of variables ($1, $2, $3 or \1, \2, \3 or $var,$var, and so on, ) holds the regular expression pattern memory. Each set of parentheses in a pattern stores the string that match the components surrounded by the parentheses into one of the $num variables.
Note 1: to use "pattern memory" of perl regular expression, user need:
* uncheck option of "Enhanced Regular Expression"
* set "Replace Unit" to "Chars"(Note: if "Replace Unit" is not "Chars", $num or \num can not be used in "Replace with pattern", but still can be used in "search for pattern" entry, example: (abc)\1 which will match abcabc)
Note 2: difference of $var[num], $num and \num:
* in "Search for pattern" entry, only \num is valid
* in "Replace with pattern" entry, all form of $var[num], $num and \num are valid
* in other windows like "if", "Run following for each matched unit" entry, only $var[num] can be used for pattern memory.
Example 1 of using Pattern Memory variables:
Text before replace: abcd AABBCCDD abcd
Search for pattern: (.)\1
Replace with pattern: \1 or $1 or $var
Text after replace: abcd ABCD abcd
Example 2 of using Pattern Memory variables:
Text before replace: AAAA begin aaaabbbbcccc end BBBB
Search for pattern: (begin)(.*?)(end)
Replace with pattern: \3\2\1 or $3$2$1 or $var$var$var
Text after replace: AAAA end aaaabbbbcccc begin BBBB