user3431399
user3431399

Reputation: 499

Regex: To match a pattern not in starting of a line

I want use regex to match a pattern (exp: double slash), that is not at the starting of a line. From the example below, I would like to match the double slash of line 5 and line 7 only. I am new to regex, hope to get some help from pro here :) Thanks in advance

// This is line 1
// This is line 2
// This is line 3

                 Something // This is line 5

                 Something // This is line 7
// This is line 8

Upvotes: 0

Views: 50

Answers (1)

anubhava
anubhava

Reputation: 785156

You can use this regex with negative lookahead:

(?!^)\/{2}

RegEx Demo

(?!^) is negative lookahead that means don't match // at line start.

Upvotes: 1

Related Questions