Questions tagged [regex]

When asking regex questions, always add the tag for the specific programming language or tool (e.g., Perl, Python, or Java; vi, emacs, or ɢɴᴜ grep; etc.) you are using.

720 questions
3
votes
2 answers

nginx rewrite regex for API versioning

What I want is for the first to be turned into the second.. /widget => /widget/index.php /widget/ => /widget/index.php /widget?act=list => /widget/index.php?act=list /widget/?act=list =>…
MSpreij
  • 85
  • 1
  • 9
3
votes
1 answer

Use of backreferences in fail2ban filters possible?

From time to time, I see collections of suspect "File not found" errors in my Apache logs, basically using the pattern File does not exist: /var/www/file, referer: http://my.server.com/file In human terms: The file was not found, though it…
Izzy
  • 349
  • 1
  • 5
  • 19
3
votes
1 answer

How to make comments in logcheck files?

how can I add comments to logcheck ignore-rules? Things I tried so far: # seems to match single # characters instead of starting a comment empty lines matches against everything $ matches against everything $^ seems to be an "impossible" regex,…
Black
  • 188
  • 1
  • 13
3
votes
1 answer

Nginx - Redirect request by GET parameters pattern

One of my servers was attacked by DDoS a couple of days ago and it lasted for 4 days. Below are the logs snippet of the request: 36.224.180.253 - - [14/May/2013:03:11:46 +0800] "GET //?f5b2fd2f860dc=9597624054932145 HTTP/1.1" 301 178 "-" "Opera/9.80…
chr1x2
  • 39
  • 1
  • 5
3
votes
1 answer

How to block all incoming proxy visits except from one specific I.P?

I have a page that is prone to attacks, so, in order to reduce the anonymous attacks, I use this code in my .htaccess which I found online : # BLOCK PROXY VISITS RewriteEngine on RewriteCond %{HTTP:VIA} !^$…
user169759
3
votes
1 answer

How do I use "catchall" in my postfix alias?

I have this in my main.cnf: alias_maps= regexp:/etc/aliases Inside that file, I have: /^reply*$/: jjj Now, when I send it to reply-124233@mydomain.com, postfix bounces it because Recipient address rejected: User unknown in local recipient…
Alex
  • 8,471
  • 26
  • 75
  • 99
3
votes
1 answer

htaccess email regex

I am trying to write a patter in such a way that this link : http://www.mysite.com/link/go/emailadress@gmail.com is interpreted like this : http://www.mysite.com/process.php?email=emailadress@gmail.com But i dont know how to write. I tryied this but…
pollux1er
  • 131
  • 6
3
votes
2 answers

NGINX Reverse Proxy : proxy_cache inside if block - Possible?

I think starting with a small snippet would be wisest: location ^~ /test/ { proxy_pass http://frontend; proxy_http_version 1.1; proxy_set_header Connection ""; …
anonymous-one
  • 1,018
  • 7
  • 27
  • 43
3
votes
1 answer

Regular expression not working on Powershell

Background: I need to match a multiline pattern(?) in a C# source file. The regular expression will be manipulate by Powershell. I have tested and it works on RegexBuddy (with the Dot Matches newline". But when I try to use it via powershell, it…
thugzclub
  • 61
  • 1
  • 3
  • 4
3
votes
1 answer

Fail2Ban SASL Filter Misses Failed Logins

I am using fail2ban on my mail server. I discovered this morning that there were some 5000 failed login attempts (in the course of 1 hour) via SMTP that didn't get picked up by my sasl filter. Here is an example of an entry in…
AJ.
  • 332
  • 4
  • 14
3
votes
2 answers

How can I count instances of a regex match in a log file using PowerShell?

I have a very large log file in which I need to count the occurrences of all the variations of a particular string; that is: There are a large number of file IDs that appear in the format AA000####. I have to find out what the top five or ten IDs…
Doug Chase
  • 753
  • 3
  • 12
  • 22
3
votes
2 answers

egrep matching group not printing?

I'm trying to create a bash script that will grep lines from a file using egrep. I've created the regex that should group the information I want, the issue is trying to get the output. I've been testing it with the following command but nothing is…
krizzo
  • 387
  • 2
  • 5
  • 16
3
votes
2 answers

apache question mark RewriteRule question

So i am trying to redirect from index.php?action=search&query=search text goes here to search?query=search text goes here i tried this so far but with no luck RewriteRule ^search/? index.php?action=search&query=$1 [QSA,L] EDIT : Solution…
stergosz
  • 129
  • 2
  • 7
3
votes
2 answers

nginx location regex matches directory range

I am trying to set up nginx and I don't get the point how to do the following setup: I have an URL http://somehost.com/foo/bar/123/xxx_xxx that needs to be passed to different backends depending on a range the '123' matches (e.g. 0-150 -> backend1,…
Sascha
  • 538
  • 2
  • 5
  • 12
3
votes
2 answers

Lex Flex variant that will do the Perl REGEX extensions

I use flex & lex a lot for stripping stuff from e-mail attachments in scritps. I wondered if there are moden versions and variants of the lex programs that have the perl REGEX extensions. I know the boost libs support perl style but this is not…
kingchris
  • 244
  • 4
  • 13