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):
Related
I have received a very long file. It has 1000+ lines of SQL code. Each line start with line number.
14 PROCEDURE sp_processRuleset(pop_id IN NUMBER);
15
16 -- clear procedure for preview mode to clean crom_population_member_temp table and global variables
17 PROCEDURE sp_commit; -- 28-Oct-09 J.Luo
18
19 -- The rule Set string for the Derived Population Member Preview
20 -- The preview mode will set gv_context_ruleSet by setContext_ruleSet,
21 -- sp_processRuleset uses gv_context_ruleSet to build derived population instead of getting rules from crom_rule_set table
22 gv_context_ruleSet VARCHAR2(32767) := NULL; -- 27-Oct-09 J.Luo
23 -- The population Role Id for the Derived Population Member Preview
I want to remove only line numbers using NotePad++ Find+Replace functionality. Is there any regex available to get this done ?
This using regex is the easiest way.
Other handy way (scrolling a 1K lines is not much IMO) could be :
Block Selection using ALT key and dragging your mouse, like following:
You can use this regex:
^\d+
Working demo
Open Replace window with CTRL+H and run Replace All with these settings:
Find what: ^\s*\d+
Replace with: (empty)
Search mode: Regular expression
Notes:
\s can also be [[:space:]] or [ \t]
\d can also be [[:digit:]] or [0-9]
If the new edit is correct, the pattern \s* that matches the leading space may not be needed.
You can use this one if you have colon after numbers
^\d+:
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.
How can I write this as a regular expression?
tabspaceSTRINGtabspace
My data looks like this:
12345 adsadasdasdasd 30
34562 adsadasdasdasd asdadaads<adasdad 30
12313 adsadasdasdasd asdadas dsaads 313123<font="TNR">adsada 30
1232131 adsadasdasdasd asdadaads<adasdad"asdja <div>asdjaıda 30
I want to get
12345 30
34562 30
12313 30
1232131 30
\t*\t doesn't work.
try the following regular expression
\t.+\t
The problem there is your definition of String...
If you use something like the suggested above, it'll match
tabspaceSTRINGtabspacetabspace
You get the picture. This might be acceptable, if not, you need to limit your "STRING" definition, like:
\t\w+\t
or:
\t[a-zA-Z]+\t
What characters are allowed in your string?
\t\w+\t
\w would allow letters, digits and the underscore (depending on your regex engine ASCII or Unicode)
See it here on Regexr, a good platform to test regular expressions.
Your "regex" \t*\t would match 0 or more tabs and then one tab. The * is a quantifier meaning 0 or more and is referring to the character or group before (here to your \t)
If your whitespace are not tabs, try this
\s+.+\s+30
\s is a whitespace character (space, tab, newline (not important for Notepad++)).
If you are not sure about the strings you are looking for except that they are separated by tabs it is a good approach to describe such a string as everything but a tab: (^\t*)
[^\t]*\t([^\t]*)\t[^\t]*
You can test it on regexpad.com.
I need to add a parameter for each code and name, i tried using (.+) or (.*) for each number, but it didnt work. Each space means that is a different number and not every space has the same width. Example from this:
Abanda CDP 192 129 58 0 0 0 2 3 3
2.998 0.013 33.091627 -85.527029 2582661
To this:
Abanda CDP |code1=192 |code2=129 |code3=58 |code4=0 |code5=0 |code6=0 |code7=2 |code8=3 |code9=3
|code9=2.998 |code10=0.013 |code11=33.091627 |code12=-85.527029 |code13=2582661
Try ([0-9.-]+). The reason .+ doesn't work is because . matches whitespace as well. The reason you can't just use \S+ (non-spaces) is because you only want to match the numbers.
I'd like to be able to match this entire line (to highlight this sort of thing in vim): Fri Mar 18 14:10:23 ICT 2011. I'm trying to do it by finding a line that contains ICT 20 (first two digits of the year of the year), like this: syntax match myDate /^*ICT 20*$/, but I can't get it working. I'm very new to regex. Basically what I want to say: find a line that contains "ICT 20" and can have anything on either side of it, and match that whole line. Is there an easy way to do this?
.*ITC 20.*
should do the trick. . is a wildcard that matches any character, and * means you can have 0 or more of the pattern it follows. (i.e. ba(na)* will match ba, banana, bananananana and so on)