Sample Header Ad - 728x90

How to create a regex matching a custom string at the beginning of line while ignoring all preceding whitespaces via ag silversearcher?

0 votes
0 answers
246 views
Give an example file with the content: // find me val ignore me = "" // I should not be found // find me // find me I want to find all the lines with find me using ag silversearcher. Basically, it should match any line optionally starting with any white space and a double space //. I know that: ag ^// example only yields in the first line without spaces. For the beginning of the line I know I can use ^, for whitespace it should be \s, and my custom string should either be // or it may need to be to escaped to: \/\/ That's why I thought: ag ^\s*// example ag ^\s*\/\/ example Should do the trick, yet it finds also only the first line. How can I match all the lines starting with white space and my custom string?
Asked by k0pernikus (16549 rep)
Nov 30, 2018, 04:10 PM