How to delete all lines matching a pattern and a line after in Vim?
You can use :g/word/normal 2dd This finds all instances of word and then executes the command after it. In this case it executes 2dd in normal mode
You can use :g/word/normal 2dd This finds all instances of word and then executes the command after it. In this case it executes 2dd in normal mode
You may replace all non-digit characters using the \D+ regex and an empty string replacement with =REGEXREPLACE(A11,”\D+”, “”) or with casting it to a number: =VALUE(REGEXREPLACE(A11,”\D+”, “”))
Using regular expressions to validate a numeric range To be clear: When a simple if statement will suffice if(num < -2055 || num > 2055) { throw new IllegalArgumentException(“num (” + num + “) must be between -2055 and 2055”); } using regular expressions for validating numeric ranges is not recommended. In addition, since regular … Read more
You could search for: <li><a href=”#”>[^\n]+ And replace with: $0</a> Where $0 is the whole match. The exact semantics will depend on the language are you using though. WARNING: You should avoid parsing HTML with regex. Here’s why.
You can use a lookahead for this, the shortest would be to use a negative lookahead: type ([a-z])(?![\w-]) (?![\w-]) would mean “fail the match if the next character is in \w or is a -“. Here is an option that uses a normal lookahead: type ([a-z])(?=[^\w-]|$) You can read (?=[^\w-]|$) as “only match if the … Read more
sed -i ‘s/WORD1.*WORD3/WORD1 foo WORD3/g’ file.txt or sed -i ‘s/(WORD1).*(WORD3)/\1 foo \2/g’ file.txt You might need to escape round brackets, depends on your sed variant.
This will capture up to but not including the second comma: [^,]*,[^,]* English translation: [^,]* = as many non-comma characters as possible , = a comma [^,]* = as many non-comma characters as possible […] is a character class. [abc] means “a or b or c”, and [^abc] means anything but a or b or … Read more
In VIM: :g!/^[+-]/d Here is the English translation: globally do something to all lines that do NOT! match the regular expression: start of line^ followed by either + or -, and that something to do is to delete those lines.
I think in Visual Studio, you can mark expressions with curly braces {txtSomeNum.Text}. Then in the replacement, you can refer to it with \1. So the replacement line would be something like Int32.Parse(\1). Update: via @Timothy003 VS 11 does away with the {} \1 syntax and uses () $1