New CADforum look launched.
Over 1.088.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new Engineering calculator. New AutoCAD 2026 commands and variables.
Over 1.088.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new Engineering calculator. New AutoCAD 2026 commands and variables.
Download of CAD utilities
Download
srxTEXT - search and replace AutoCAD drawing texts using regular expressions, supports batch scripts, table replacements, numeric intervals (free): [ + show all files ]

File
Size
Date
Info
--
srxTEXT - search and replace AutoCAD drawing texts using regular expressions, supports batch scripts, table replacements, numeric intervals (free)
SRXTEXT - search/replace with regular expressions
(C)2024, ARKANCE - CAD Studio https://arkance.world
--------------------------------------------------------
SRXTEXT is a LISP utility for AutoCAD 2000/i, 2002-2025,
which can search and/or replace drawing texts (TEXT,
MTEXT, DIMTEXT, ATTRIB, ATTDEF, MULTILEADER).
You can choose from exact string match, substring
match/replace or regular expressions. For the
regular expression functionality, AutoCAD Express
Tools may be required (part of AutoCAD installation).
You can search (and replace) the whole drawing,
any specified layer or selected objects.
SRXTEXT zooms to any matching text and offers to
Replace, Autoreplace (Yes to all), Skip to next,
skipAll or Exit the
search/replace loop.
SRXTEXT contains three commands - SRXTEXT, SRXTEXT2,
SRXTEXTCSV and SRXMISSING.
The preferred SRXTEXT2 command uses VBscript regular
expression engine (instead of Express Tools) to perform
regular exp. replacements. Use the older version SRXTEXT
only for compatibility reasons. You can also force
srxText to VBscript mode by setting the LISP variable:
(setq _srxRegEx "VB")
The "CSV" version loads the search-replace string pairs
from a .CSV text file so you can predefine complex
replacements e.g. in Excel. The .CSV file is in format:
"whattofind1","whattoreplace1"
"whattofind2","whattoreplace2"
(sample file included)
Since version 1.5 the quotes are optional and the delimiter
can be "," or ";".
SRXMISING is a special command which can identify texts
(numbers) missing from a given numeric interval. If you
should have e.g. doors numbered 1-100, it can find the
door with forgotten number in a series.
Regular expressions:
--------------------
Please note that the regular expression syntax differs in
the old Express Tools version and in the VBscript version -
SRXTEXT2.
Using regular expressions you can perform complex
replacements like changing:
D19-457-03667
to
Part:457/03667 Code:D19
For this case you would use the search and replace
strings:
\([A-Z][0-9][0-9]\)\-\(...\)\-\(.*\)
Part:\2/\3 Code:\1
and in SRXTEXT2:
([A-Z][0-9][0-9])-(...)-(.*)
Part:$2$3 Code:$1
SrxText supports a subset of standard regular expression syntax,
SrxText2 supports the whole VBscript regex syntax. The subset:
. Matches any single character.
* Postfix. Preceeding item 0 or more times.
+ Postfix. Preceeding item 1 or more times.
^ Matches empty string at beginning of text.
$ Matches empty string at end of text.
[chars] Matches any character in the given class. If the first
character is ^, match any character not in the given class. A
range of character may be specified by first-last, as in [A-Z]
to specify upper case alphabetic characters or e.g. [0-9]
\( Mark the beginning of a subexpression.
\) Mark the end of a subexpression.
\digit Matches a repeat of the text matched earlier by the
subexpression inside the nth opening parenthesis. Subexpressions
may also be referenced in replace strings.
EXAMPLES:
You can append strings to the beginning of your
texts:
^\(.\)
newprefix\1
or to the end of your texts:
\(.\)$
\1newsuffix
in SRXTEXT2:
^(.)
newprefix$1
Or you can replace just the first occurrence of
a substring in text:
search: \(.\)oldtext\(.\)
replace: \1newtext\2
in SRXTEXT2:
(.)oldtext(.)
$1newtext$2
Another example of complex replacements:
KWD-5-3, KW-4-2, KWP-1-5
change to:
KCD-5-1, KC-4-1, KCP-1-1
search: \(.\)W\(.*\)\-\(.\)\-\(.\)
replace: \1C\2-\3-1
in SRXTEXT2:
(.)W(.{0,1})-(.)-(.)
$1C$2-$3-1
Cutting the number of decimal places to 1:
search: \([0-9]*\)\.\([0-9]\)[0-9]*
replace: \1.\2
in SRXTEXT2:
(\d*)\.(\d)\d*
$1.$2
Adding a thousands separator (",") to numbers.
search: -?\([0-9]+\)\([0-9][0-9][0-9]\)
replace: \1,\2
in SRXTEXT2:
-?(\d+)(\d\d\d)
$1,$2
(repeat it for million/billion/... triplets)
Delete all text after the first period in text:
search: ^\([^\.]*\)\..*
replace: \1.
in SRXTEXT2:
^([^\.]*)\..*
$1.
Replace trailing "A"s with "B"s:
search: \(.\)A$
replace \1B
in SRXTEXT2:
(.)A$
$1B
Delete trailing spaces:
search: \(.\) +$
replace: \1
in SRXTEXT2:
(.) +$
$1
Delete color control codes in MTexts:
search: \(.\)\{\\C[0-9]+;\(.\)
replace: \1\2
in SRXTEXT2:
(.)\\C\d+;
$1
Adding trailing text to texts not containing "*":
search: ^\([^\*]+\)$
replace: \1 NewTrailingText
in SRXTEXT2:
^([^\*]+)$
$1 NewTrailingText
Erasing the first character in the text:
search: ^.\(.*\)
replace: \1
in SRXTEXT2:
^.(.*)
$1
Replacing hard returns with soft returns in MText:
search: \\P
replace: _ (single space character)
in SRXTEXT2:
\\P
_
Use replacement in scripts:
---------------------------
You can use ScriptPro or other script processor to
perform batch replacements on multiple DWG files.
The script could look like e.g.:
(load "srxtext.vlx")
srxtext
s
oldtext
newtext
all
all
d
- or just -
(load "srxtext.vlx")
(srxtext "Substring" "oldtext" "newtext" "All")
Tip 1:
MTEXT objects can contain hidden control character
codes, so they may appear to not meet the exact
matches (btw, you can use SRXTEXT to remove these
control characters)
Tip 2:
You can use srxText to add, modify or delete control
characters in MText texts - changing the string height,
color, font, width, etc. E.g. {\T2.0;XXX}
Tip 3:
set _SRXTEXTNOZOOM to T (true) to disable running zooms:
(setq _SRXTEXTNOZOOM T)
set _srxTEXTCSVen to T (true) to use old "comma only"
separators when processing CSV files
Tip 4:
SRXTEXTCSV honors the FILEDIA setting so you can enter
the .CSV file name on the commandline (e.g. in batch
scripts) with FILEDIA=0
Tip 5:
If you need to enter regular expression strings in menu
macros, you cannot use backslashes, use (chr 92) instead.
E.g. the LISP version of srxtext (replace "\\"->"|"):
(srxtext "Regular" (strcat(chr 92)(chr 92)) "|" "All")
Tip 6:
Use (setq _srxRegEx "VB") to force all srxText functions
using regular expressions to the VBscript engine.
You cannot replace strings in text generated by Fields.
Character case must match exactly (case-sensitive) - not
in regular expressions.
Since version 1.1 you can replace MTexts longer than
256 characters.
Since version 1.4 you can enter the searched text by picking
en existing text entity.
Since version 2.0 you can use the VBscript engine - default
in the SRXTEXT2 command.
SRXTEXT contains also a LISP interface so you can
use the srxText functionality in our LISP routines:
(srxTEXT "" "" "" "")
or
(srxTEXT2 "" "" "" "")
can be Substring or Regular or Exact (case sensitive)
is the searched string
is the replacement string
can be "All", or a name of an existing layer,
or "Select" to select objects interactively, or a
selection set variable with selected objects
returned value is the number of replacements done
Examples:
(srxTEXT "Substring" "Ford T1" "Ford Galaxy" "All")
(srxTEXT "Exact" "Autocad" "AutoCAD" myselectionset)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
in Czech (česky):
Regulární výrazy:
SrxText podporuje podmnožinu syntaxe standardních regulárních
výrazů, SrxText2 podporuje celou syntaxy z VBscript. Podmnožina:
. odpovídá jakémukoliv jednomu znaku
* přípona - předchozí položka se může opakovat 0 nebo vícekrát
+ přípona - předchozí položka se může opakovat 1 nebo vícekrát
^ odpovídá prázdnému znaku na začátku řetězce
$ odpovídá prázdnému znaku na konci řetězce
[znaky] odpovídá jakémukoliv znaku dané třídy. Pokud je prvním
znakem ^, odpovídá jakémukoliv znaku kromě dané třídy. Lze zadat
rozsah znaků pomocí první-poslední, tedy např. [A-Z] určuje
znaky velké abecedy nebo např. [0-9] číslice
\( označuje začátek zapamatovaného podvýrazu
\) označuje konec zapamatovaného podvýrazu
\číslice označuje text dříve zapamatovaný podvýrazem v N-té otevírací
závorce. Podvýrazy lze odkazovat v řetězcích pro nahrazení.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
License: SRXTEXT is a free/trial utility by CAD Studio,
do not publish it online on other than CADstudio's
web servers, do not sell, lend or exchange it.
----------------------------------------------------
Contact:
Arkance Systems CZ (CAD Studio)
Libalova 1, 149 01 PRAHA, Czech Republic
info@cadstudio.cz www.cadstudio.cz www.cadforum.cz
21kB
21.11.2024
V2.6
The file is a compressed ZIP archive. You can unpack it using your Windows Explorer, or WinZIP, or similar application. Then follow the contents of the ZIP package.
How to load a LISP application (.LSP/.VLX) into AutoCAD? See the Tip 7245.
Many other files also on ARKANCE Helpdesk, CAD blocks in the Block catalog.
PARTNERSHIP
ARKANCE UK Community - portal
IT CAD - magazine
BIMfo - BIM portal
F360 - Fusion portal
twiGIS - GIS/FM software
CAD NEWS


