Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pattern-matching]

The tag has no usage guidance.

0
votes
2answers
18 views

Nginx location match multiple extensions unless path starts with specific word

How can I write a location block that matches any path ending in the following extensions: jpg|jpeg|gif|css|png|js|ico|json|xml|txt|html Unless the path starts with "/rails" (eg: /rails/randomstring/...
0
votes
2answers
265 views

In Nginx config, how to limit regex matching?

In the nginx config file for my server, I have written the following location block: location ~ /page/(?!(3/?|5/?|6/?|8/?)) { return 301 https://anothersite.com/page$is_args$args; } With this, I'...
0
votes
1answer
233 views

How can I match requests for known mime types containing query strings, in nginx?

I'm using nginx to serve assets statically, and also route all non-asset requests to a PHP front controller. I have a location block that looks like: location / { include /etc/nginx/mime.types; ...
0
votes
1answer
348 views

Nginx How to set location static files to match with jsessionid

I'm working on Nginx to add cache headers on my static files and works. I'm using this location location ~* \.(ico|css|js|gif|jpeg|jpg|png|woff|ttf|otf|svg|woff2|eot)$ { expires 30d; ...
0
votes
1answer
27 views

Return result only if multiple strings exist in a file

Is there a Linux utility which will return the name of a file only if it contains multiple specified strings? Not necessarily on the same line. Obviously grep can "OR" but I'm looking for "AND".
0
votes
2answers
645 views

syslog-ng prepending date to received logs, breaking patterns in patterndb

I'm setting up central logging for our servers using syslog-ng + patterndb, however the logs the logging server is receiving from the client are prepended with the date, host and other data. This of ...
-6
votes
1answer
66 views

Using pattern matching to reduce IP Spoofing [duplicate]

The IP Spoofing is becoming a major concern these days.I was wondering whether we could use pattern matching,like comparing the hop count of the packets coming or the TTL(Time To Live) field of the IP ...
0
votes
1answer
452 views

Lighttpd, regex in conf, path including regex match

The background : - Lighttpd 1.4.28 - Debian 6.0.7 i686 Several developers are using this web server, and each of them has his own virtual host named after "username.mysite.tld". These hosts are ...
1
vote
1answer
11k views

RewriteCond not matching on my IP when matching on %{REMOTE_ADDR} [duplicate]

I want a mod_rewrite rule not to be executed when traffic is hitting the web-server from internal network. The web server is an apache 2.2 The following RewriteCond is meant to guard the rewrite rule. ...
2
votes
1answer
777 views

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....
2
votes
2answers
186 views

Display nth instance of grepped pattern

So here's my problem. I have an issue with a .csv file (Current.csv) in that there are commas randomly place throughout the data, so awk-ing the file doesn't give me constant column numbers for a ...
0
votes
1answer
2k views

match 2 numbers in extensions at asterisks dialplan

is there a simple way to match something like this: exten => _+380XXXXXXXXX,1,NoOp(hint that) exten => _0XXXXXXXXX,1,NoOp(hint that) this two extensions matches same number with or without +38 ...
2
votes
2answers
2k views

How to find .h,.c and .cc files under current directory in linux?

find . -name "*.[hc]|*.cc" The above doesn't work,why? UPDATE How do I find these 3 kinds of files with a single pattern?
1
vote
2answers
956 views

finding a group of string common in two files

I have used diff command in past.I faced a situation to which I did not had a clue here are some text strings (which can be stored in a file) CONFIG_XEN=y CONFIG_XEN_PVHVM=y ...
2
votes
3answers
3k views

How to delete everything except .svn directories?

I have quite complex directory tree. There are many subdirectories, in those subdirectories beside other files and directories are ".svn" directories. Now, under linux I want to delete all files and ...
2
votes
1answer
1k views

makefile shell pattern expansion: how to?

I have found an interesting "feature" of make DIR_INPUT=/test test: # testing date (it should be yesterday) test ! -z "${DATE}" ls -lad ${DIR_INPUT}/{a,c} but it seems to ...
1
vote
4answers
2k views

How to do a text match in bash

I'm trying to find a nice way of checking some text in order to set a variable. For instance to perform the logic: 'if the version string is 1.x then set a flag'. One way of doing this is: ...
3
votes
4answers
2k views

How can I specify a shell pattern that excludes certain files?

For instance, I want to remove all the files in a directory except for the .tar file from whence they came. I could do something like: find . -maxdepth 0 | grep -v '.tar$' | xargs rm -f but is there ...