spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » REGEX » Page 1
PHP running multiple instance issue
You may be able to remove the extra process by changing the shell_exec line to: shell_exec("exec /usr/bin/php /srv/www/videofix.d.com/public_html/v/complete.php"); This makes the executed shell replace itself with the command rather than forking a new process for it. (This trick works for me under Linux, under OSX and FreeBSD no extra shell lingers.)

Categories : Regex

Using regex to find a double quote within string encased in double quotes
For the example you gave just "w" works as the regex to find "C" Try it here The replacing mechanism is probably built into ultraedit

Categories : Regex

Regex that makes IPV6 addresses shorter
You can use python's socket module to get >>> socket.getaddrinfo('1034:0123:0000:2100:3120:0000:0022:0001', 0, socket.AF_INET6) [(10, 1, 6, '', ('1034:123:0:2100:3120:0:22:1', 0, 0, 0)), (10, 2, 17, '', ('1034:123:0:2100:3120:0:22:1', 0, 0, 0)), (10, 3, 0, '', ('1034:123:0:2100:3120:0:22:1', 0, 0, 0))] >>> socket.getaddrinfo('1034:0123:0000:2100:3120:0000:0022:0001', 0, socket.

Categories : Regex

How can I require that at least two lookahead patterns match within one regex?
you would have to do something like : ^( (?=1)(?=2) | (?=1)(?=3) | (?=1)(?=4) | (?=2)(?=3) | (?=2)(?=4) | (?=3)(?=4) ).*$ where 1,2,3 & 4 are your different patterns

Categories : Regex

How to Text Mining Specific Data
You can use a regex like (d+).*(.s(?:mitochondria|mitochondrial|mitochondrion)[^;]+;) The capture groups 1 and 2 will contain O95831 ;mitochondrial respiratory chain complex I assembly; Example : http://regex101.com/r/mR8xA7/1 Python code would be like >>> re.findall(r"""(d+).*(.s(?:mitochondria|mitochondrial|mitochondrion)[^;]+;)""", str) [('095831', '; mitochondrial respirato

Categories : Regex

Using sed to replace IP using regex
Two problems here: sed doesn't like PCRE digit property d, use range: [0-9] or POSIX [[:digit:]] You need to use -r flag for extended regex as well. This should work: s='123.123.123.123' sed -r 's/([0-9]{1,3}.){3}[0-9]{1,3}/222.222.222.222/' <<< "$s" 222.222.222.222 Better would be to use anchors to avoid matching unexpected input: sed -r 's/^([0-9]{1,3}.){3}[0-9]{1,3}$/222.222.22

Categories : Regex

Whats wrong with this RewriteRule for .htaccess
You need to use proper RewriteBase by placing this rule in /users/.htaccess: RewriteEngine On RewriteBase /users/ RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([0-9a-z]+)/?$ index.html?userID=$1 [L,QSA,NC]

Categories : Regex

Regular Expression in JMeter 2.12
Because you made a mistake with the quotes: <a href="siw_portal.url?([^"]+)".......title="Your course" // __^ __^ __^ __^ instead of <a href='siw_portal.url?([^"]+)'.......title='Your course'

Categories : Regex

How to in JMeter use regular expression extractor to fill request in loop
Your test plan should be in the format mentioned in the attached snapshot: Hope this will help

Categories : Regex

How to replace value between xml tags using regex in Ant?
< and > characters must be "escaped" by using &lt; and &gt; respectively: <replaceregexp file="WEB-INF/web.xml" byline="true" match="((?&lt;=session-timeout&gt;)[Ss]*?(?=&lt;/session-timeout))" replace='20'/>

Categories : Regex

Regular expression extractor issue in Jmeter
Use Regular expression extractor with below regular expression, cuen=(.*)" onMouseOver In regex extractor you can provide which occurance you want to extract. Match no. is the name of parameter and its value shoud be 1 in your case for first match. use this as reference : Regular Expression Extractor

Categories : Regex

Regular Expression in xml parsing
perl -pe 's/^.*xlink:href="//; s/">$//' file Example: sdlcb@Goofy-Gen:~/AMD/SO$ cat file <ext-link ext-link-type="uri" xlink:href="http://<xref&#x00A0;rid="x0026;AN=15230473">http://web.ebscohost.coms/ehost/detail&#x0026;#x003F;sid=d1f06770-cd74-4496-ae7b-7689ed05c6c4%40sessionmgr10&#x0026;#x0026;vid=1&#x0026;#x0026;hid=23&#x0026;#x0026;bdata=JnNpdGU9ZWhvc3QtbGl2

Categories : Regex

awk – how to put a regexp in a variable if I want to use it within if/else logic?
You need to store and reuse regex like this: gawk 'BEGIN {animals = "cat|dog"; digits = "[[:digit:]]+" } { if ($0 ~ animals) { print "animal" } else if ($0 ~ digits) { print "number" } else { print "unknown" } }' path/to/input.txt > path/to/output.txt i.e. don't use regex delimiter while storing it in variable.

Categories : Regex

Regular Expression in Vim
The fragment you're looking for might be ([^;])*;, if you're not really concerned whether it's exactly two words. Or (s+w+s+w+s*);, if you need it to be two words only.

Categories : Regex

.htaccess 302 redirects with regular expression replacement
You can use this code in your DOCUMENT_ROOT/.htaccess file: RewriteEngine On RewriteCond %{THE_REQUEST} s/+(?:index.php)??search=([^s&]+) [NC] RewriteRule ^ /%1? [R=302,L,NE] ## replace of space with - # executes **repeatedly** as long as there are more than 1 spaces in URI RewriteRule "^(S*) +(S* .*)$" /$1-$2 [L,NE] # executes when there is exactly 1 space in URI RewriteRule "^(S*) (S*)$

Categories : Regex

Regular expression for a comma separated string
Break your problem into steps. First look for allowed format and characters. Then check to make sure there is no repetition. use strict; use warnings; while (<DATA>) { print if /^[ACGT]+,[ACGT]+$/ && !/(w)w*1/; } __DATA__ A,G AG,CT TC,CA GAT,CGA CGAT,TG ,G ACGT X,A AA,G AC,GGC ATGA,TGG ATCXG,AAC Outputs: A,G AG,CT TC,CA GAT,CGA CGAT,TG

Categories : Regex

perl regular expression using repetition/quantifier
You really want this: ( my $nine ) = ( $var =~ /(d{9})/ ); The problem is that =~ is a comparison operator, and the result of the expression ( $var =~ /d{9}/ ) is true (1). Adding the parentheses in my example makes the regex capture its matches, so it returns your 123456789.

Categories : Regex

Extracting string before pattern with sed (bash)
It sounds like you can pretty much use exactly what you had in your question: sed 's/.*S[0-9][0-9]E[0-9][0-9].*//' This matches an optional . character followed by the pattern you suggested (and anything after it), replacing with nothing. You were missing a ] in the question, which I have added. Testing it out: $ sed 's/.*S[0-9][0-9]E[0-9][0-9].*//' <<<'The.100.S02E05.720p.HDTV.x264-

Categories : Regex

grep outputs differently for pip list vs pip list -o
The problem with the pattern is .* because the . tries to match anything including space where as we intent not to include space. A little change in the pattern can do the work $ pip2 list --outdated | grep -o '^[^ ]*' Here rather than trying to match anything, .* we attempt to match anything other than a space [^ ]* What it does? ^ anchors the regex at the starting of string [^ ]* matches a

Categories : Regex

regular expression that tests if string is empty
How does /^$/ match empty string ^ matches the begining $ matches the end of the string. Since there is nothing betweent the two anchors, the string is empty Example : http://regex101.com/r/kK9aW2/1 Note when we write a regex /ab/ matches an a and immediately followed b It doesnt mean that it matches a or b in the string. It means it matches ab in the string That is the regex matches ab

Categories : Regex

.htaccess Internal Redirect issue
Yes it will cause looping because RewriteCond %{REQUEST_FILENAME} !-f will still be true for /test.php when /test.php doesn't exist. You can use this code to prevent looping: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] # don't redirect after one internal redirect RewriteCond %{ENV:REDIRECT_STATUS} .+ Rewrite

Categories : Regex

Search and retrieve patterns from a list
Got it: the searchpos function with the 'p' flag allows you to retrieve the position and the id of the match in for a compound pattern, see :help searchpos.

Categories : Regex

regex, append a find with string
The following expression will match cells in the format A1 or $A$1 not preceeded by ' (?<!'!)([A-Z]{1,3}[0-9]+|$[A-Z]{1,3}$[0-9]+) http://regex101.com/r/yO8rW1/2

Categories : Regex

Matching multiple Uppercases in string with patterns and $BASH_REMATCH
With bash builtins: str="Hello World" for ((i=0;i<${#str};i++)); do [[ ${str:$i:1} =~ [[:upper:]] ]] && echo ${str:$i:1}; done Output: H W

Categories : Regex

RegEx lookahead but not immediately following
Here is one non-lookaround based regex: (berg|gebergte) Use it with i (ignore case) flag. This regex uses alternation and word boundary to search for complete words berg OR gebergte. RegEx Demo Lookaround based regex: (?<=ge)berg(?=te)|berg This regex used a lookahead and lookbehind to search for berg preceded by ge and followed by te. Alternatively it matches complete word berg u

Categories : Regex

How to redirect all visitors but search engine bots using htaccess
To allow all bots, you can implement a do nothing rule, e.g. RewriteCond %{HTTP_USER_AGENT} (bot|spider) [NC] RewriteRule ^ - [L] This rule triggers for all visitors, which have either bot or spider in their user agent string. You can be more specific of course, if you want only a few bots like Google, Yahoo and Bing. When the condition is met, nothing else happens. To redirect everybody else

Categories : Regex

Regex: Matching a part of last part of URL?
.*?_(.*)</b>$ Try this.Grab the capture.See demo. http://regex101.com/r/yP3iB0/4 or ^.*?_|</b> Try this.Replace with empty string.See demo. http://regex101.com/r/yP3iB0/5

Categories : Regex

What's the meaning of the '\|o+' in `string-split' function?
"\|" specifies an alternative between the expressions on either side, so the regexp "\|o+" matches either an empty string, or one-or-more "o"s. In your first example you've returned the two empty strings separated by the three "o"s. In the second example the empty string separator matches at every character in the input, so each character is returned separately.

Categories : Regex

Matching files using wildcards
You can't do that with a simple diff. You could do something like this though: set -f while IFS=, read pattern match ; do grep "$pattern" >/dev/null <<<"$match" || { echo ERROR ; exit 1 ; } done < <(paste -d, master output) Assuming master is the master file and output is the output file. There are several important things to keep in mind: The master file should contain r

Categories : Regex

Regular expression to match everything at beginning and end
Seems like the expression "This.*sentence" will give you everything. That is, it matches This, then all characters, then sentence. If either This or sentence is missing, then it won't match.

Categories : Regex

How do I delete matching text with sed but keep the rest of the line?
sed deletion operates over the matched line. So, in your exammple, you'd be deleting the entire line. You should head for substitutions instead. Take a look at the examples below: $ sed -E 's/(.*)-[0-9]+.[0-9]+.[0-9]+(.*)/12/' <<< "Dropbox-1.0.0-win32-setup.exe" Dropbox-win32-setup.exe $ sed -E 's/(.*)-[0-9]+.[0-9]+.[0-9]+(.*)/12/' <<< "gdrive-2.32.1-linux.deb" gdrive-l

Categories : Regex

Regex, Word contains x but doesn't start with x
Your attempt didn't work because you confused a negated character class (defined with [^...], but able to cover just a single character by definition) with a negative lookahead (defined with (?!...)). Have you written this properly, it would have looked like that: ^(?!end).+end.*$ ... with + instead of * right after the preceding . for obvious reasons. ) Note that more straight-forward attem

Categories : Regex

awk and regexp from file
You can use something like $ awk 'NR % 2 { for (i=1; i<=NF; i++) if ($i ~ /[eoy]$/) print $i}' input apple tomato empty What it does? NR % 2 selects the lines 1 3 5... if ($i ~ /[eoy]$/) checks if each field, wrod ends with a e or o or y

Categories : Regex

Using regex to parse a delimited array in bash
A sed solution can be like $ sed -r '/points=/ s/[^,]+,?([0-9]*)/1 /g' input 287 470 509 459 471 OR for much better handling $ sed -r '/points=/ s/.*points=("[^"]+").*/1/g; s/[^,]+,?([0-9]*)/1 /g' input 287 470 509 459 471

Categories : Regex

How to write this in regular expression
Assuming you don't want to allow leading zeroes (i.e., have 01 be invalid), then it's trivial: ^[1-9][0-9]*$ Works with nearly all modern regex engines, not just PCRE. Explanation: ^ # Start of string [1-9] # Match one digit between 1 and 9 [0-9]* # Match zero or more digits between 0 and 9 $ # End of string

Categories : Regex

How to capture specific string inside a double quotes
try this: /"([a-z0-9.]+)"/mi allow character puts in [allow char] live demo php $re = "/"([a-z0-9.]+)"/mi"; $str = ""icici","1001","50.0" "hdfc","2001","10.0","20.0""; preg_match_all($re, $str, $matches); var_dump( $matches[1]); or $str=""; if(count($matches[1])>0) foreach($matches[1] as $k=>$v){ $str .="\$k"."->".$v."&nbsp;&nbsp;"; } echo $st

Categories : Regex

Get part of string between specific symbols
This can depend on the programming language and regex library you are using. (s.*?;) Should work. This will produce 1 match for each SQL statement. If you can add your language to the question it may help in case you get a different output. The main interesting bit here is the non-greedy operator ?, which stops it matching across the whole string and matches the shortest length possible. http

Categories : Regex

How to remove the symbol "" in a string?
Seems like you want something like this, > a <- c("1 "US"","2 "UK"","3 "GE"") > gsub(""", "", a) [1] "1 US" "2 UK" "3 GE" OR > a <- "1 "US", 2 "UK", 3 "GE"" > gsub(""", "", a) [1] "1 US, 2 UK, 3 GE" > gsub(""|,", "", a) [1] "1 US 2 UK 3 GE" " are usually used to mean a double quotes.

Categories : Regex

Find number between quotes
Just make the , in your regex as optional by adding the ? quantifier next to ,. $(Select-String totaldisksize $Path*.xml).line -replace '.*totaldisksize="(d+,?d+)".*','$1' OR $(Select-String totaldisksize $Path*.xml).line -replace '.*totaldisksize="(d+(?:,d+)*)".*','$1' DEMO Regular Expression: ( group and capture to 1: d+ digits (0-9) (1 or mo

Categories : Regex


Recently Add
Regex with or statement
PHP running multiple instance issue
Using regex to find a double quote within string encased in double quotes
Regex that makes IPV6 addresses shorter
How can I require that at least two lookahead patterns match within one regex?
How to Text Mining Specific Data
Using sed to replace IP using regex
Whats wrong with this RewriteRule for .htaccess
Regular Expression in JMeter 2.12
How to in JMeter use regular expression extractor to fill request in loop
How to replace value between xml tags using regex in Ant?
Regular expression extractor issue in Jmeter
Regular Expression in xml parsing
awk – how to put a regexp in a variable if I want to use it within if/else logic?
Regular Expression in Vim
.htaccess 302 redirects with regular expression replacement
Regular expression for a comma separated string
perl regular expression using repetition/quantifier
Extracting string before pattern with sed (bash)
grep outputs differently for pip list vs pip list -o
regular expression that tests if string is empty
.htaccess Internal Redirect issue
Search and retrieve patterns from a list
regex, append a find with string
Matching multiple Uppercases in string with patterns and $BASH_REMATCH
RegEx lookahead but not immediately following
How to redirect all visitors but search engine bots using htaccess
Regex: Matching a part of last part of URL?
What's the meaning of the '\|o+' in `string-split' function?
Matching files using wildcards
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.