Abacre Home > Advanced Find and Replace Home

Evaluation of expressions

With this feature it's possible to make almost any kind of operations within an expressions: subtract or add numbers, convert to upper/lower cases, trim spaces and even make conditional replacements (using IFF function). See detailed list of functions below.

The feature works with Replace with part of batch replace pair.

Evaluate expressions is activated by Modifier E in Bath Replace tab of Options window.

Expressions should be enclosed in <%==%> braces.

Normally you should pickup a text using () in search for and then put the text as parameters $1, $2 and so on.

For example if you need to convert a text into upper case: Use Search for: (\w+) and Replace with: <%=Upper("$1")=%>

Explanations: \w+ means more than one alphanumeric char. So it will pickup all words. <%= =%> - delimits the expression. function Upper() converts supplied text into upper case. $1 means a found word. "$1" is used because function Upper() converts strings. So by using "" we specify that supplied parameter is a string.

It's possible to use any combination of functions inside expressions, for example: <%=($1+1)*3/4+$2=%> More sample cases: case1, case2

Complete list of functions and data types:

Variable types:
x,y numeric - (integer, float)
a,b boolean (1 or 0)
s,t,v string
d DateTimeString (StampString)

Basic operations:

numeric x + y , x - y , x * y, x / y, x ^ y
compare x > y, x < y, x >= y, x <= y, x = y, x <> y
ansi compare s > t, s < t, s >= t, s <= t, s = t, s <> t
boolean (1/0) a AND b, a OR b, NOT(a)
boolean (1/0) x in [...] // example: 12 in [22,12,3]
set variable x:=formula (or value) ;
destroy variable FreeVar(s); // s=variable name
logical ExistVar(s) // s=variable name
formula separation with semicolon formula1 ; formula2


Type conversion:

boolean (1/0) Logic(x)
numeric Numeric(s)
string String(x)
char Char(x)
integer Ascii(s)

all types Eval(f) // where f is formula in [...]
string NumBase(x,base) // base from <2..16>
integer BaseNum(s,base) // base from <2..16>


Math operations:

numeric (integer): x Div y, x Mod y


Math functions:

Abs(x), Frac(x), Trunc(x), Heaviside(x) or H(x), Sign(x),
Sqrt(x), Ln(x), Exp(x),
Cos(x), CTg(x), Ch(x), CTh(x), Sin(x), Sh(x), Tg(x), Th(x),
ArcSin(x), ArcCos(x), ArcTg(x), ArcCtg(x),
MaxVal(x [,y, ...]), MinVal(x [,y, ...]),
SumVal(x [,y,...]), AvgVal(x [,y, ...])

String operations:

s || t ,
s Like t, // (%,_)
s Wildcard t // (*,?)


String functions:

integer: Length(s), Pos(t,s)
string: Trim(s), TrimLeft(s), TrimRight(s), Upper(s), Lower(s),
Copy(s,x,[y]), CopyTo(s,x,[y]), Delete(s,x,[y]),
Insert(s,t,x);
Replace(s,t,v,[1/0=ReplaceAll,[1/0=IgnoreCase]] );
IFF(a,s,t); //IF a>=1 then Result:=s else Result:=t
WrapText(s,MaxCols,BreakChars,BreakStr)
Format(s,x)


Date & Time functions:

integer: Year(s), Month(s), Day(s), WeekDay(s),
Hour(s), Minute(s), Sec(s)
numeric: StrToStamp(d) LastDay(x) // last day in Month (28-31)
string: StampToStr(x), StampToDateStr(x), StampToTimeStr(x)

See also: syntax of regular expressions, regular expression builder, regular expressions FAQ