New TEX user here. I have a homework assignment for a regular expression:
RE = /\bgrotto\b.\braven\b.|\braven\b.*\b grotto\b/
However, every time I put \b, it sees it as a function. How can I get around this? Thank you!
I can think of two solutions:
replace all instances of \ in the string with \textbackslash
Use inline verbatim mode, as the string expresses computer code
\documentclass{article}
\usepackage[T1]{fontenc} % needed to render "|" correctly in text mode
\newcommand\tb\textbackslash
\begin{document}
RE = /\tb bgrotto\tb b.\tb braven\tb b.|\tb braven\tb b.*\tb b grotto\tb b/
\verb+RE = /\bgrotto\b.\braven\b.|\braven\b.*\b grotto\b/+
\end{document}
\textbackslashinstead. – Bernard Apr 04 '20 at 13:39