how can I exlude all files except one in Atomiq using regex - regex

I'm trying to use the Atomiq tool to check only one file for duplicate code. However there is only a regex exclusion option.
I've tried using .*(?!filename) to exclude all negative results which doesn't work. Does anybody have an idea?

Try following regex to get your result
(.*)filename

Related

How to check for spaces before <?php?

I'm building APIs using Laravel, and for some reason, the response generated seems to add a new line before returning the response. An example of this issue is explained in this link.
I suspect this is because there is an empty space or new line character before the opening tags in one of the PHP files. I was wondering what's the easiest way to find it? I use PHPStorm, and it has a regex search option. I am quite clueless as to how to use it to find the files though. Any ideas?
You could use \s+<\?php. To remove the spaces, replace the matches with <?php.

Rewrite regex without negation

I have wrote this regex to help me extract some links from some text files:
https?:\/\/(?:.(?!https?:\/\/))+$
Because I am using golang/regexp lib, I'm not able to use it, due to my negation (?!..
What I would like to do with it, is to select all the text from the last occurance of http/https till the end.
sometextsometexhttp://websites.com/path/subpath/#query1sometexthttp://websites.com/path/subpath/#query2
=> Output: http://websites.com/path/subpath/#query2
Can anyone help me with a solution, I've spent several hours trying different ways of reproducing the same result with no success.
Try this regex:
https?:[^:]*$
Regex live here.
The lookaheads exist for a reason.
However, if you insist on a supposedly equivalent alternative, a general strategy you can use is:
(?!xyz)
is somewhat equivalent to:
$|[^x]|x(?:[^y]|$)|xy(?:[^z]|$)
With that said, hopefully I didn't make any mistakes:
https?:\/\/(?:$|(?:[^h]|$)|(?:h(?:[^t]|$))|(?:ht(?:[^t]|$))|(?:htt(?:[^p]|$))|(?:http(?:[^s:]|$))|(?:https?(?:[^:]|$))|(?:https?:(?:[^\/]|$))|(?:https?:\/(?:[^\/]|$)))*$

Sublime on Save Build exclude pattern

I installed a Sublime plugin called "SublimeOnSaveBuild" which compiles my sass files while saving. But now I'm going to work with more than just one file.
The plugin offers a filter function which is checking if the filename matches the pattern \\.(sass|less|scss)$.
But i need a pattern which matches any file that is not preceded by an underscore.
I tried \\(?!_).*.(sass|less|scss)$ but this doesn't work.
Any ideas what is wrong with this pattern?
The result should be that file.sass gets compiled but not _file.sass.
I assume that this patern should work: ^(?<!_)[a-z-]*\.(sass|less|scss)$
This part: (?<=_) is called positive lookbehind assertion.
You can do some tests here: https://regex101.com/r/gN8uX1/2
As the answer of streetturtle did not work for me, i found another solution on https://joshuawinn.com/ignore-sass-and-less-partials-starting-with-underscore-when-using-sublimeonsavebuild/ which is
(/|\\\\|^)(?!_)(\\w+)\\.(css|js|sass|less|scss)$

Textmate Regex Issue

I have a very large .CSV document with text I need removing. The data looks like this
774431994&images=774431994,774431996,774431998,774432000,774432003,774432006,774432009&formats=0,0,0,0,0 /1/6/9/5/2/6/8/webimg/774431994
774431996&images=774431994,774431996,774431998,774432000,774432003,774432006,774432009&formats=0,0,0,0,0 /1/6/9/5/2/6/8/webimg/774431996
774431998&images=774431994,774431996,774431998,774432000,774432003,774432006,774432009&formats=0,0,0,0,0 /1/6/9/5/2/6/8/webimg/774431998
774432000&images=774431994,774431996,774431998,774432000,774432003,774432006,774432009&formats=0,0,0,0,0 /1/6/9/5/2/6/8/webimg/774432000
774432003&images=774431994,774431996,774431998,774432000,774432003,774432006,774432009&formats=0,0,0,0,0 /1/6/9/5/2/6/8/webimg/774432003
774432006&images=774431994,774431996,774431998,774432000,774432003,774432006,774432009&formats=0,0,0,0,0 /1/6/9/5/2/6/8/webimg/774432006
774432009&images=774431994,774431996,774431998,774432000,774432003,774432006,774432009&formats=0,0,0,0,0 /1/6/9/5/2/6/8/webimg/774432009
I'm using the following Regex which is working on http://regexr.com/3a6oa
/.{128}(?=webimg).{10}/g
It just doesn't seem to work with Textmate Search. Does anyone know why? I need to select all of this junk and replace it with nothing, the numbers are unique each time.
Thanks very much
Why are you using a lookahead in your pattern? Just use: /.{128}webimg.{10}/g
Why are you using Textmate search at all? I'd need to know more context of the problem to say for sure, but I bet a simple sed command could just be used instead:
sed -i "webimg/d" ./filename.csv

Issues with RegEx

I am trying to make an if-then-else statement using RegEx. I want to match the text if it contains Monty and also contains Python. Also the text should get matched if Monty is not present in the text.
RegEx
(?(?=Monty)(?(?=Python).*|)|^.*).*$
Kindly help!
How about this:
(^(?!.*Monty(?!.*Python.*).*).*$|^.*Python.*Monty.*$)
This passes my tests, but let me know if it works for you.
I am not versed in lookahead regex but just tried to build the regex from what I understood from above description. Check the link to see if this is what you are trying to do.
try this instead
((?=Monty)((?=Python).*|)|^.*).*$