2

There's this really cool new set of features in resharper 9. Particularly regarding Regex and the syntax highlighting. This post gives a good overview of how it works.

Basically, by putting your cursor on any string, and choosing this context command: Before known as regex

Will result in this highlighting: enter image description here

I want to know where resharper stores the reference to that string, and how it will then know it is a regular expression.

I can't find it in resharper settings anywhere (besides turning the feature on and off). Any idea where it could exist?

1 Answer 1

4

It seems that this information is stored in the solution cache, because after deleting the cache, the manually triggered highlighting of regex strings disappear.

Anyways, by using typed regexes, R# automatically highlights them:

Regex field

If you really have to use strings, you could alternatively use the following trick utilizing the RegexPattern code annotation attribute.

RegexPattern attribute

Sign up to request clarification or add additional context in comments.

1 Comment

Oh! That is a clever way of going about it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.