Questions tagged [posix-ere]

The POSIX Extended Regular Expression is the regex flavor used by the UNIX/Linux egrep command.

For more information about this regex flavor, see:

89 questions
0
votes
1 answer

Does Bash support non-greedy regular expressions?

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…
deanresin
  • 1,466
  • 2
  • 16
  • 31
0
votes
0 answers

Extended regex "." seems not to be matching everything

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…
jackscorrow
  • 682
  • 1
  • 9
  • 27
0
votes
2 answers

POSIX-ERE: Match a word but not when between square brackets

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…
0
votes
2 answers

Escaped sequence for apt regex

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…
StephenG
  • 2,851
  • 1
  • 16
  • 36
0
votes
1 answer

posix regular expression for parsing uevent causing error

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…
noman pouigt
  • 906
  • 11
  • 25
0
votes
1 answer

RegExp for a comma-separated list of terms that finds terms not ending or starting with a character

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…
Wollo
  • 60
  • 1
  • 8
0
votes
1 answer

Help with a regular expression

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…
Ben G
  • 26,091
  • 34
  • 103
  • 170
0
votes
1 answer

Eregi to preg_replace change for php 5.3 compatibility

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…
Paul M
  • 3,937
  • 9
  • 45
  • 53
0
votes
1 answer

Problem with ereg deprecated

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…
0
votes
2 answers

ereg to preg conversion

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!!!!
musoNic80
  • 3,678
  • 9
  • 40
  • 48
0
votes
2 answers

eregi replace replacement

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…
apis17
  • 2,825
  • 2
  • 23
  • 23
0
votes
2 answers

Yet another php ereg fix

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) :…
casben79
  • 25
  • 4
0
votes
2 answers

Why is the following regex not working in C using regcomp

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…
Karthik H
  • 123
  • 1
  • 11
0
votes
2 answers

PHP: How to use ereg to validate input text AND string length simultaneously?

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…
andreszs
  • 2,896
  • 3
  • 26
  • 34
0
votes
1 answer

Converting an eregi_replace to a preg_replace

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…
rickhuby
  • 174
  • 10