Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Microsoft.VisualStudio.Text.Operations.FindData and Regular Expressions

$
0
0

I'm developing a VSPackage using MEF and trying to find all trailing space in the current document using ITextSearchService.FindAll, but I'm having problems with FindData's regular expressions. It doesn't seem to follow any regex rules I can figure out. It even gives me different results from the C# RegEx class.

I've tried all variations I can think of, but it never seems to work the way I want it to. Specifically, I want the whitespace *between* the last non-whitespace character and the newline (so excluding \n and \r).

In regular expression, \s matches whitespace, including \r and \n. So to get the trailing whitespace, you can do:

"@"\s+$"

...however that will include the \n and \r characters.

The following works everywhere else I tried it, *except* in FindData:

@"[^\S\n\r]+$"

...or...

@"\s+(?!.+\S)"

...etc.

Does anyone know what expression will give me *only* the white space characters, and exclude the \n and \r characters when using FindData?


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>