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
8
votes
1 answer

Extracting part of the string using Ansible regex_search and save the output as a variable

I'm having a content like below inside a file. dataDir=/var/lib/zookeeper 4lw.commands.whitelist=mntr,conf,ruok,stat syncLimit=2 I wanted to read the value for dataDir using Ansible and set it to a variable. I have written following code but…
AnujAroshA
  • 213
  • 1
  • 3
  • 7
7
votes
2 answers

Why does this regex not work on linux?

I can't say it works on Windows but from my understanding this regex is correct and how I would write it (except maybe the ^ at the beginning) From…
user274
7
votes
4 answers

nginx error log Grok pattern

I am having trouble getting the following nginx error log message to parse in the grok debugger. I have a feeling there is a stupid trick that I should use but can't figure out what it may be. 2015/03/20 23:35:52 [error] 8#0: *10241823 testing…
jmreicha
  • 790
  • 1
  • 16
  • 29
7
votes
2 answers

nginx url rewriting. i just don't get it

Ok, an example url is http://www.mysite.com/?p=account&view=settings the p uri is a constant. all urls have it. the view is one of many optional uri. i've tried to understand url rewriting and regex, but i'm just not getting it. I need to be back…
r3wt
  • 202
  • 1
  • 3
  • 10
7
votes
1 answer

Is there a tool that can top-ify an input stream?

I come across quite a few use cases where it would be very useful to take input from a (usually newline-delimited) stream and summarise it in a top-like fashion (see top, iotop, etc). A kind of on-the-fly pivot table. e.g. Take the log-esque…
7
votes
6 answers

Globally Coloring the Terminal by Regex

I know many programs use color - (vim, ack, color-ls to name a few) but there are still many cases where you're stuck with black and white. There are scripts that will color output based on regular expressions (i.e. "make anything that matches 'dog'…
Jimmy
  • 293
  • 3
  • 7
7
votes
1 answer

How do I format this regex so it will work in fail2ban?

I've just installed fail2ban on my CentOS server in response to an SSH brute force attempt. The default regular expressions in fail2ban's sshd.conf file do not match any entries in audit.log, which is where SSH seems to be logging all connection…
chapkom
  • 181
  • 1
  • 2
  • 9
6
votes
1 answer

apt-get install packages matching wildcards

I am running Debian 8 Jessie, trying to install PHP command line intepreter from a shell script. Here is what I do: sudo apt-get install php-cli it tells me there is no php-cli. I do find there is php5-cli. However, to make my script more robust,…
xrfang
  • 185
  • 1
  • 1
  • 10
6
votes
1 answer

nginx regex characters that require quoting?

So I was configuring nginx today and I hit a weird problem. I was trying to match a location like this: location ~ ^/([0-9]+)/(.*) { # do proxy redirects } ...for URLs like "http://my.domain.com/0001/index.html". This rule was never matching,…
6
votes
5 answers

apache locationmatch negative regex

I'm trying to expose a location through Apache. Normally, I have this block in my vhost that says AuthType Basic AuthUserFile /web/.htpasswd AuthName "Test Site" Require valid-user This works just fine -…
Jeff
  • 61
  • 1
  • 1
  • 2
6
votes
7 answers

Copy multiple folders to a single destination with robocopy

I'm looking for a solution to use robocopy to copy several folders from a directory onto a distant network share. I want to choose several folders out of a directory that contains hundreds of folders I'm not interested in. I want to do something…
SDGuero
  • 228
  • 1
  • 2
  • 4
6
votes
2 answers

Regex negative look-ahead is not working for mod_rewrite between different Apache versions

I have a mod_rewrite line that works under Apache 2.2, but not under Apache 1.3: RewriteRule ^(?!index.php)(?!skin/)(?!js/)(.+) /index.php?file=$1 [NC,L] If I lose the negative look-ahead components between the brackets, I…
tjbp
  • 193
  • 3
  • 6
6
votes
1 answer

I can not seem to get a Regex for to Fail2Ban to work with Opensmtpd? Can I get a sanity check?

I have openSMPTD running a mail server. It seems I am getting brute forced attacked currently, although I doubt they will get in. That being said, I would like to alleviate the burden on my server with the constant log-in attempts. I am configuring…
David Frick
  • 179
  • 2
5
votes
1 answer

Ansible split string on backslash

I'm passing a list of dir/subdirs into a playbook as follows: dirs=['Web\this','Web\that','Web'] This works fine when I actually do tasks on those directories (win_shell, invoking a build process), but later I need to copy the files and the '\'…
Wolske
  • 53
  • 1
  • 1
  • 6
5
votes
2 answers

fail2ban find matches, but does not ban

I am using fail2ban 0.9.7 on CentOS 7 along with an Apache reverse proxy, trying to ban bots trying to access my server as an open proxy, such as : 221.8.179.164 - - [10/Jun/2019:22:04:19 +0200] "CONNECT auth.riotgames.com:443 HTTP/1.1" 405 235 "-"…
ojathelonius
  • 61
  • 1
  • 4
1 2
3
47 48