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 (just display the strings), seLect to perform just the selection of matching texxts, or Exit the search/replace loop.
SRXTEXT contains four 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 SRXTEXTCSV loads the search-replace string pairs from a .CSV text file so you can predefine complex replacements e.g. in Excel. The expected .CSV file is in the format:
"whattofind1","whattoreplace1" "whattofind2","whattoreplace2"(sample file included)
Since version 1.5 the quotes are optional and the delimiter can be "," or ";".
The CSV version is in Trial mode only (first 2 pairs are processed). Use the CADSTUDIOREG command to authorize it.
SRXMISSING 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(s) with forgotten number in a series.
Working with regular expressions is an important part of the srxText functionality. Please note that the regular expression syntax differs in the old Express Tools version and in the VBscript version of the command - SRXTEXT2.
Using regular expressions you can perform complex replacements like changing:
D19-457-03667to
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:\1and 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.
^\(.\) newprefix\1
\(.\)$ \1newsuffixin SRXTEXT2:
^(.) newprefix$1
search: \(.\)oldtext\(.\) replace: \1newtext\2in SRXTEXT2:
(.)oldtext(.) $1newtext$2
search: \(.\)W\(.*\)\-\(.\)\-\(.\) replace: \1C\2-\3-1in SRXTEXT2:
(.)W(.{0,1})-(.)-(.) $1C$2-$3-1
search: \([0-9]*\)\.\([0-9]\)[0-9]* replace: \1.\2in SRXTEXT2:
(\d*)\.(\d)\d* $1.$2
search: -?\([0-9]+\)\([0-9][0-9][0-9]\) replace: \1,\2in SRXTEXT2:
-?(\d+)(\d\d\d) $1,$2
(repeat it for million/billion/... triplets)
or, more flexible (SRXTEXT2):
(\d)(?=(\d{3})+\b) $1,
search: ^\([^\.]*\)\..* replace: \1.in SRXTEXT2:
^([^\.]*)\..* $1.
search: \(.\)A$ replace \1Bin SRXTEXT2:
(.)A$ $1B
search: \(.\) +$ replace: \1in SRXTEXT2:
(.) +$ $1
search: \(.\)\{\\C[0-9]+;\(.\) replace: \1\2in SRXTEXT2:
(.)\\C\d+; $1
search: ^\([^\*]+\)$ replace: \1 NewTrailingTextin SRXTEXT2:
^([^\*]+)$ $1 NewTrailingText
search: ^.\(.*\) replace: \1in SRXTEXT2:
^.(.*) $1
search: \\P replace: _ (single space character)in SRXTEXT2:
\P _
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.
Since version 2.3, srxTEXT is FREE.
Since version 2.4, you can use the Select option.
SRXTEXT contains also a LISP interface so you can use the srxText functionality in our LISP routines:
(srxTEXT "<mode>" "<search>" "<replace>" "<layers>")or
(srxTEXT2 "<mode>" "<search>" "<replace>" "<layers>")
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 syntaxi 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í.
SRXTEXT is a free utility by CAD Studio (ARKANCE), do not publish it online on other than CADstudio's web servers, do not sell, lend or exchange it.
Download the srxText application (for AutoCAD 2025-2000)