在 LaTeX 中编写正则表达式
在我制作的 LaTeX 报告中,我必须编写一个正则表达式。整个报告只有一个,所以我不太想使用包之类的东西。
这是我正在谈论的正则表达式:
^\"((\w|\s)+)\"$
我为 LaTeX 想出了这个:
\grave{ }\backslash\"'((\backslash w\| \backslash s)+)\backslash \"' \backslash \$
这给了我大约 10 个错误,而且我真的看不出哪里出了问题。好吧,看起来很糟糕,但所有命令都应该有效。
预先感谢,
伤害
In a LaTeX report I am making I have to write a regex. There is only one in the whole report, so I don't really want to use packages and so on.
This is the regex I am talking about:
^\"((\w|\s)+)\"$
I came up with this for LaTeX:
\grave{ }\backslash\"'((\backslash w\| \backslash s)+)\backslash \"' \backslash \$
This gives me like 10 errors, and I can't really see what is wrong. Okay, it looks pretty bad but all the commands should work.
Thanks in advance,
Harm
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
Use
也许问题是其中一些命令(\反斜杠,\grave)想要处于数学模式,但“没有。您是否尝试过使用 \verb 逐字包含正则表达式?我不确定它是否会看起来像你想要的(它将以 tt 字体排版),但你可以用类似的东西来做到这一点:
...
在我的项目中,我使用正则表达式
\verb@^\"((\w |\s)+)\"@
做一件事......
Perhaps the problem is that some of those commands (\backslash, \grave) want to be in math mode, but " doesn't. Have you tried using \verb to include the regexp verbatim? I'm not sure if it'll look like you want (it'll be typeset in a tt font), but you could do this with something like:
...
In my project I'm using a regexp
\verb@^\"((\w|\s)+)\"@
to do a thing....