开发者

Writing a regex in LaTeX

开发者 https://www.devze.com 2022-12-24 16:11 出处:网络
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.

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 advan开发者_如何学Cce,

Harm


Use \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.

...

0

精彩评论

暂无评论...
验证码 换一张
取 消