1

I am using TeXStudio as my editor.

I encounter some difficulties in finding the regular expressions that can match strings occupying several lines.

For example, I need a regular expression that matches the patter $...$, namely anything (including line breaks) enclosed by two $'s.

I tried the regular expression \$[\s\S]*\$, but it only works when there is no line break between the two $'s. On the other hand, when I test this regular expression on the following website, this regular expression works for line breaks.

https://regexr.com/

I would like to know what is special about regular expressions in TeXStudio.

1

To answer your closing question: I don't think TeXStudio supports multi-line matching in the way you are describing. I can't seem to find a lot of documentation on its regex engine, but there is a lot of variation in regex implementation that leads to differences like this.

To help with the problem you are having: other editors do support multi-line matching like this - to varying degrees. If you want to just tag the instances like this and then edit them manually, Notepad++ has multi-line matching that will suffice. In my own experience with this issue, I needed to copy and paste out all of the matches in an efficient way - something Notepad++ cannot do, but Sublime Text can.

P.S. I think your regex should be \$[\s\S]*?\$ - with the added ? to make the * "lazy." Otherwise, I think it will keep matching until it runs out of $s to match on. Though, again, maybe that all depends on the regex implementation...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.