What does * of * matches mean in Sublime Text 2? - regex

When you do a (regex) search in Sublime Text 2, it shows for example "230 of 973 matches". What does this mean? One would think that means that 230 of the 973 matches are selected, but this is not the case because only one match is selected by default.

It simply means that the 230th match from the beginning of the file is being selected, from the total of 973 matches.
At the beginning of the file, you should be getting 1 of 973 matches, because the first match will be highlighted.

Related

GSheets - remove everything *after* a word (but keep the word)

How can I remove everything after a specific word (while keeping the word)?
I want to remove everything after the word 'films'.
"George Fellini 194 films 273 169 Edit" would turn into "George Fellini 194 films"
"Rick Bathista 7 films 10 27 Edit" would turn into "Rick Bathista 7 films"
There are many posts that are similar but aren't google sheets specific, and the two google sheets specific answers I've found eliminate the word I want to keep.
(It would be a bonus if it could also keep the singular "film" but not necessary.
What I've tried:
=REGEXEXTRACT(B2,"(.*) films .*") - deletes the word 'films'
=regexreplace(B2,"films ","") - also deletes the word 'films'
my sheet: https://docs.google.com/spreadsheets/d/1UL0cvdgbwJIAPSJTxajxM7_pw_pPqxq-Ofmt8uK6J6o/edit?usp=sharing
Use this formula:
=REGEXEXTRACT(B2,".*films?")
The documentation of REGEXEXTRACT says:
Extracts matching substrings according to a regular expression.
The regular expression matches any sequence of zero or more characters (.*) followed by film and an optional s (s?).
use:
=INDEX(IFNA(REGEXEXTRACT(B2:B, "(.+films)")))
() - extract group of something
.+ - all characters / anything
(.+films) - extract group of all characters ended by films included

Find a String from a varying number block to the end

I have nearly 8000 lines of the following text:
DIL 2 M 006 SC SCHÜTZ 083 1 Stck
25215-1 BIN-SORT 2152310251724-1 BIN-SORT getestet 048 133 Stck
RBBE60-T3dsg 21S003 SEALING 6X8.9X2.4 MM 082 3 Stck
I am only interested in the 3 digit block at the end and the number behind.
So this should be the output:
083 1
048 133
082 3
It could be, that the same number e.g. 048 appears at the beginning of the line. this shouldn't be a hit.
Unfortunatelly i have no idea how to extract this strings with the help of notpad++.
This expression,
.*(\d{3}\s+\d+).*
with a replacement of $1 is likely to work here.
The expression is explained on the top right panel of this demo if you wish to explore/simplify/modify it.
You may try the following find and replace, in regex mode:
Find: ^.*?(\d+ \d+) \S*$
Replace: $1
The logic here is to use .* to consume everything up until the last two consecutive digits in the line. Then, we replace with only the captured two digits.
Demo

Notepad++ `Find in Files` displays all results except a certain keyword

I am using notepad++ to search for certain keywords (using regular expression). something like (word1|word2|this statement|another statement). It works but can I search and show all results except a certain keyword? something like exclude the following words (exclude this|exclude this)? For example, below.
samedir\File1.log
This is line 1
This is line 2
This is line 3
exclude this
This is line 4
This is line 5
This is line 6
not excluded
excluding this
samedir\File2.log
This is line 1 1
This is line 2 1
This is line 3 1
exclude this
This is line 4 1
This is line 5 1 1
This is line 6 1
not excluded
excluding this
For example: I want to start a find in both files (on the same directory) but exclude the lines with excluding this and exclude this
the results should show something like below
File1.log
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
not excluded
File2.log
This is line 1 1
This is line 2 1
This is line 3 1
This is line 4 1
This is line 5 1 1
This is line 6 1
not excluded
You can do this with a lookahead assertion:
^(?!excluding this|exclude this)[^\r\n]*$
This will match entire lines as long as they don't contain excluding this or exclude this.
The key is the (?!) part. See http://www.regular-expressions.info/lookaround.html for more info.
You could try the regex like below to match all the lines which don't have exclude or excluding this strings.
^(?!.*\bexclud(?:ing|e) this\b).+$
DEMO
This (?!.*\bexclud(?:ing|e) this\b) negative lookahead at the start asserts that there isn't a string exclude this or excluding this present on the the line in which we are going to match. That is , the above regex would match all the lines except the one which contains exclude this or excluding this
I wanted to exclude one string and search for two strings in one line, so I used this regex:
^(?!.*excludethisstring).*includethisstring1.*includethisstring2.*$
This will make it so that the one line searched MUST have the two strings included, if you want to search for either one of the lines:
^(?!.*excludethisstring).*(includethisstring1|includethisstring2).*$

Matching a line not containing a word in Notepad++

I am trying to match the lines in following not input NOT containing "VelSign" (using Notepad++):
#MARKER VelSign 457.45 50 kmh
#MARKER IsBridge true
#MARKER TrafficSign 45
#MARKER TrafficLight 45 445 444 40
I am using the following regex:
^#MARKER (?!.*VelSign).*$
Doesn't seem to work. What am I doing wrong?
Make sure that you upgrade Notepad++ to version 6, as they changed quite a lot in the regex engine. Especially line breaks and lookarounds were a bit problematic in earlier versions.
Turn this:
^#MARKER (?!.\*VelSign).*$
Into this:
^#MARKER (?!.*VelSign).*$
You are escaping the * operator, which causes the match of a literal * instead of 0 or more ..
Also, make sure that you have checked the RegularExpression option (see the third radio button):

Regex matches only first Pattern and not subsequent Patterns

In the sample below:
MARY 2.629 3,991,060 1
PATRICIA 1.073 1,628,911 2
LINDA 1.035 1,571,224 3
BARBARA 0.98 1,487,729 4
ELIZABETH 0.937 1,422,451 5
In this sample I want to select the characters other than the names and remove them.In Eclipse, using Find and Replace with Regex, Find : ([0-9,\.\s\n]*)$Replace: \n
It just finds the matching characters in first line, 2.629 3,991,060 1
And not in other lines.What am I doing wrong?
Use (\d|\.|,|\s)+ in find expression and \n in the replace expression of Eclipse to achieve what you want. It will replace all the characters that occur after the initial text characters.