How come my regex pattern isn't lazy? It should be capturing the first number, not the second.
Here is a working bash script..
#!/bin/bash
text='here is some example text I want to match word1 and this number 3.01 GiB here is some extra text…
I have a file containing this header FIELD1 FIELD2 : 0x30070040 and a lot of junk characters (half the file's size). To get rid of all of them I execute these commands:
dos2unix -q -n file
sed -i $'s/[^[:print:]\t]//g' file #Removing every…
I’m trying to match occurrences of the word “organization” but not when it occurs in between square brackets:
Example strings:
The organization “[organization name]” must contain at least one
user per organization.
The ID [id] for…
Is there any way to natively escape a sequence in apt's regex?
I have a search, for example libpng++, where I want to literally match the ++ part of the string. I know that I can manually escape the ++ with \+\+, but I need to escape the string…
I am trying to parse uevent using this below code but I think my regular expression is not proper causing regcomp function to fail.
Can anyone help? I am trying to do something like this.
#include
#include
#include…
I have a String containing a comma-separated list of terms, like this:
term1, term2* ,term3*,term 4 , *term5, *term 6 , term 7*,* term 8
Each term may have leading or trailing whitespaces. These should be ignored. Each term may have whitespaces…
I'd like to write a regular expression that checks that a line is:
Delimited (by a comma, for example)
Has at least n # of delimited items (say 10, for example)
The items in the delimited list need not be alphanumeric. Some will have special…
I have this line in one of my scripts and its throwing a deprecated error.
eregi_replace( '\.([a-z]{3,4})$', "-{$width}x{$height}.\\1", $src );
Can someone show me how to turn this into preg_replace and tell me why and which bits of it need to…
Can some please help me to rewrite these code:
if (eregi($asked,$accepted)) {
$this->plot_type = $which_pt;
return true;
} else {
$this->DrawError('$which_pt not an acceptable plot type');
return false;
}
Any help will be highly appreciated, I…
I'm a complete novice when it comes to regex. Could someone help me convert the following expression to preg?
ereg('[a-zA-Z0-9]+[[:punct:]]+', $password)
An explanation to accompany any solution would be especially useful!!!!
since eregi replace was deprecated on version 5.3 i want to make my program compatible with new version of php
http://php.net/manual/en/function.eregi-replace.php
so, i'm trying to use preg_replace like this
preg_replace(",",'','20,000.00');
but…
I have a small chunk of coding I need to take from ereg to preg_match. Here is the code.
function be_file_list($d, $x) {
foreach (array_diff(scandir($d), array('.', '..')) as $f) {
if (is_file($d . '/' . $f) && (($x) ? ereg($x.'$',$f) :…
I have the following regex to match the last pair of braces in a string,
.+(?={)(.+)(?=})
The example string is,
abc{abc=bcd}{gef=hij}
I want the contents within the last braces (gef=hij) inside the captured group. This works in a regex tester…
I'm using ereg in the followin way to validate a field which can contain only numbers from 0 to 9:
if(eregi("^([0-9])*$", $mynumber)) return true;
However the string must have between 8 and 10 characeters. Is it possible to improve the same ereg…
I am trying to parse some HTML snippets and want to clean them up for various reasons (XSS et al).
I am currently trying to remove all of the attributes on any tag, except for the href on a anchor. I am doing this using a sequence of eregi_replace…