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

fail2ban jail not working properly

I'm trying to block non-available script requests to nginx with fail2ban. # Noscript filter /etc/fail2ban/filter.d/nginx-noscript.conf: # # Block IPs trying to execute scripts such as .php, .pl, .exe and other funny scripts. # # Matches e.g. #…
stUrb
  • 165
  • 2
  • 8
2
votes
3 answers

Perl regex expression

I have the following string produced by a server log file. I am using Simple Event Correlator (which uses perl regex) to manipulate lines: 18:37:31 643.65.123.123 []sent /home/mydomain/public_html/court-954fdw/Chairman-confidential-video.mpeg 226…
2
votes
2 answers

Nagios check_http - checking tomcat application status with regex & linespan

I wan't to check with our Nagios if a webapplication is running on Tomca7. I decided to use the check_http plugin with regex. I'm parsing the status-page of tomcat and check if column "Running" is true. The Sourcecode of the status-page looks like…
Arny80Hexa
  • 139
  • 1
  • 4
  • 14
2
votes
1 answer

nginx httpMapModule regex variables

The HttpMapModule documentation states that: Since 1.0.4, case insensitive regular expressions can be used by prefixing the pattern with ~*. And gives the example: map $uri $myvalue { /aa /mapped_aa; ~^/aa/(?.*)$ …
Robin Winslow
  • 209
  • 1
  • 3
  • 11
2
votes
2 answers

centos - how to find a filename with all the possible extensions?

I need to perform a search for "foo" and return all the filenames/directories with this name (e.g. foo.php, foo.txt etc). It should run through the whole filesystem and find even hidden files. I've tried find / -name 'foo' but doesn't seem to work.
user154523
  • 23
  • 1
  • 3
2
votes
2 answers

Nginx RegEx to match a directory and file

I'm wondering if it's possible to match Wordpress directory and specific file in the same location, so at the moment I've got rule to match only the wp-admin directory: ## Restricted Access directory location ^~ /wp-admin/ { auth_basic …
HTF
  • 3,148
  • 14
  • 52
  • 82
2
votes
1 answer

Convert from apache rewrite to nginx

I want to convert from apache rewrite modules to nginx RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E)…
Linux Intel
  • 183
  • 2
  • 3
  • 16
2
votes
1 answer

encapsulate text in quotes with sed buffer

I need to do a search and replace to encapsulate a variable string in single-quotes (php object notation into php array notation) such that the following block: $my_trip->trip_id = ( $my_trips_opts->trip_id > 0 ) ? $my_trips_opts->trip_id :…
Jaryd Malbin
  • 415
  • 1
  • 4
  • 6
2
votes
1 answer

Regexp in HAProxy's reqrep for asset management

I'm hosting assets on S3 with this kind of URL: http://cdn.site.com/image.jpg In my application I automatically serve versioned URL to force browser to download new files after the deployment: "/1.2.3/image.jpg" In every deployment I would only like…
user130224
  • 121
  • 4
2
votes
1 answer

Memory usage REGEX

Could you help me to modify the following one-liner to get more precise memory usage - right now it's just an integer I would like to include first value after coma. free -m | awk '/Mem:/ {tot = $2;} /cache:/{printf "%d\n", $3 / tot * 100}' Thank…
HTF
  • 3,148
  • 14
  • 52
  • 82
2
votes
1 answer

Sed multi-line replace over escaped strings

I'm attempting to convert a mysqldump output file to PostgreSQL compatible SQL. The issue is in dealing with escaped string values. I need to go from: VALUES('blah blah blah','second string \'with escaped\' quotes and multiple lines goes…
Kenaniah
  • 213
  • 1
  • 3
  • 8
2
votes
2 answers

Regular Expression for "AND"?

Let's say I gave you the following text: allow_httpd_anon_write --> off allow_httpd_mod_auth_ntlm_winbind --> off allow_httpd_mod_auth_pam --> off allow_httpd_sys_script_anon_write --> off httpd_builtin_scripting --> on httpd_can_check_spam -->…
Soviero
  • 4,366
  • 8
  • 36
  • 60
2
votes
1 answer

Recursively search and replace the contents of multiple file types

I have thousands of web files(*.php, *.htm, *.html, etc) that contain an absolute path(http://site.com/sites/etc). I need to scan a directory and all subdirectories for the various file types and within those files, modify my absolute path to a…
Publiccert
  • 1,112
  • 1
  • 8
  • 22
2
votes
3 answers

Nagios not accepting regex in command

I have this command defined: define command{ command_name check_http_sane command_line $USER1$/check_http -H $HOSTNAME$ -r "HTTP/1.1 (200|301|302|303|304|307|401|418|426)" } When I run it manually on command line, it works fine, but nagios (2.6)…
Creshal
  • 259
  • 1
  • 5
  • 16
2
votes
2 answers

Get Apache2.2 to hide Microsoft documents that are being edited?

I have a htdocs directory where I am serving a few Microsoft Word documents. When someone is editing a document, the name of the document changes to look like something like this: "~$my_document.doc" and also .tmp files are created that represent…
djangofan
  • 4,182
  • 10
  • 46
  • 59