I am trying to find all using statements that are in cs files that contain a reference to a class anywhere in the file following it.
For example, I want to match using Example.Foo;
if BaseClass<SomeClass>
is found anywhere in the file following it.
Like such:
I've tried (using Example.Foo;)(?=[.\\s\\n]*BaseClass\\<SomeClass\\>[.\\s\\n]*)
but no joy...
UPDATE
For clarity, this is for the VS 2012 IDE Find and Replace dialog.
You need to add a (?s), which enables multiline matching, and also escape the period in using Example.Foo
. The regex should be something along the lines of:
(?s)using Example\\.Foo;(?=.*BaseClass<SomeClass>)
I figured it out myself.
(?s)using Example\.Foo;(?=(.*|\s\r)BaseClass\<SomeClass\>(.*|\s\r))
This does the trick!
Thanks for the (?s)
hint, that was required! +1 for that...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.