How might one treat hyphens as hyphens (not minus) in in-line math?
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{parskip}
\renewcommand\familydefault\sfdefault
\usepackage[nominus]{mathastext}
\mathchardef\hy="2D %% https://tex.stackexchange.com/a/199504/187997
\begin{document}
\begin{enumerate}
\item $Hyphenated-text-string$
\item $Hyphenated\hy{}text\hy{}string$
\end{enumerate}
\end{document}
Item 1 treats the hyphen as a minus and replaces the hyphen by an en-dash with extra spacing.
Item 2 achieves what I need by adapting this answer.
I am using in-line math with Bmatrix*, bmatrix*, vmatrix* (for stacking and alignment), left and right braces and brackets, to express the syntax [metalanguage] of COBOL. If possible, I would prefer not having to change the hyphens in hundreds of places, particularly since minus is rarely used in the syntax of the full language.
I was rather hoping that [nominus] would do what I want, but appears to have no effect. Also, [noendash] leaves an unwanted gap.
The log shows:
Package: mathastext 2019/11/16 v1.3w Use the text font in math mode (JFB)
The proposed solution at Hyphens in mathmode, though close, involves wrapping hyphenated text inside a math font style, which, when using mathastext, I have no need to do.
If there is no way to re-configure mathastext, one solution, if possible, is to change the character recognized as minus to a character that, for my purposes, will not be used in math mode, such as circumflex ^ or exclamation !.
While the answer given in a comment works, it is important to note that without [nominus] each hyphen will be changed to an en-dash; thus, the two statements must be used together, as shown below, to prevent the hyphens from being changed.
\usepackage[nominus]{mathastext}
\DeclareMathSymbol{-}{\mathalpha}{operators}{`-}

\DeclareMathSymbol{-}{\mathalpha}{operators}{`-}should work, but imho you are misusing math here. – Ulrike Fischer Jul 08 '20 at 20:44