1

How can I match comments in page source that start in symbols "//" but skip urls that also have "//" like "https://test.test.test/testing"?

My code right now is:

Regex regex = new Regex(@"\/\/(.*?$)", RegexOptions.Multiline);
MatchCollection matchCollection1 = regex.Matches(pageSource);
string allMatches = string.Join(";", from Match match1 in matchCollection1 select match1.Groups[1].Value);
3
  • 1
    You can check my post here. Commented Jan 16, 2017 at 11:21
  • When you solve the current issue (say, with @"(?<!\bhttps?:)//(.*)"), you will come across another. This is something that requires a dedicated parser. Commented Jan 16, 2017 at 11:49
  • do a lookbehind for http? Commented Jan 16, 2017 at 12:03

1 Answer 1

1

add not present of ':' symbol and set multi line option

[^:]\/\/(.*?$)/gm

https://regex101.com/r/Z8zz0n/2

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

Comments

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.