I am trying to run some code files and find lines that do not end with a semicolon.
I currently have this: ^(?:(?!;).)*$from the Googling group, and everything works fine. But now I want to expand it so that it ignores all spaces at the beginning or specific keywords, such as a package or opening and closing curly braces.
^(?:(?!;).)*$
The ultimate goal is to take something like this:
package example { public class Example { var i = 0 var j = 1; // other functions and stuff } }
And for the template to show me that there is var i = 0no partial shade. This is just an example; a missing half-raft can be anywhere in the class.
var i = 0
Any ideas? I trained for more than an hour, but no luck.
Thank.
Try the following:
^\s*(?!package|public|class|//|[{}]).*(?<!;\s*)$
PowerShell:
PS> (gc file.txt) -match '^\s*(?!package|public|class|//|[{}]).*(?<!;\s*)$' var i = 0 PS>
, , .*, , [^;], , , \s* $. , :
.*
[^;]
\s*
$
.*[^;]\s*$
, , ^, , [^\s], :
^
[^\s]
^[^\s].*[^;]\s*$
, package , , class, , , . , , (?:\s|package|class), , -, , (?!\s|package|class). !. , :
package
class
(?:\s|package|class)
(?!\s|package|class)
!
^(?!\s|package|class).*[^;]\s*$
, , / :
, , , , , , .
str.scan(/^\s*(?=\S)(?!package.+\n|public.+\n|\/\/|\{|\})(.+)(?<!;)\s*$/)
, , :
.*[^;]$
, :
^[^ ].*[^;]$
, , , whitespace ^\s*, , (?!package|class), - .*, ( ) [^;]\s*.
^\s*
(?!package|class)
[^;]\s*
^\s*(?!package|class).*?[^;]\s*$
, .
, , Java, , java, . vim .
\(.\+[^; ]$\)\(^.*public.*\|.*//.*\|.*interface.*\|.*for.*\|.*class.*\|.*try.*\|^\s*if\s\+.*\|.*private.*\|.*new.*\|.*else.*\|.*while.*\|.*protected.*$\)\@<! ^ ^ ^ | | negative lookbehind feature | | | 2. But not where such matches are preceeded by these keywords | | 1. Group of at least some anychar preceeding a missing semicolon
:
^ beginning of line .* Any amount of any char + at least one [^ ... ] everything but $ end of line \( ... \) group \| delimiter \@<! negative lookbehind
, / . , , java, java- , , .
https://jbodah.imtqy.com/blog/2016/11/01/positivenegative-lookaheadlookbehind-vim/