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
3
votes
2 answers

How can I escape curly braces at the end of a regular expression

I have the following bash script to replace parenthesis for curly braces. VARS=${VARS//(/{} VARS=${VARS//)/}} The first line works OK, but the second one will only add a curly brace at the end. If I try to escape the curly brace with a backslash,…
jasonsantos
  • 33
  • 1
  • 4
3
votes
1 answer

How to alter my expression to return the same result while being compliant with POSIX BRE / ERE?

I'm trying to use Snowflakes regex implementation, which I have just discovered is POSIX BRE/ERE. I had previously fashioned a regex expression to allow me to identify all commas not in double quoted string sections with a custom delimiter (for text…
CaseyR
  • 75
  • 6
3
votes
2 answers

How to escape regex text in Java for POSIX Extended format

I want to quote a piece of string to be treated as a literal string inside a larger regex expression, and that expression needs to conform to the POSIX Extended Regular Expressions format. This question is very similar to this existing question,…
Oak
  • 26,231
  • 8
  • 93
  • 152
3
votes
4 answers

Why is `ereg` deprecated in PHP?

Why is ereg deprecated in PHP? I had a lot of functions which used this, now they always give warning. What is the alternative of this too?
Starx
  • 77,474
  • 47
  • 185
  • 261
2
votes
2 answers

Why is this regular expression match positive?

Given the pattern ^[a-zA-Z0-9 .\-_]+$ and the string te\\st, why is the match positive? I'm using this to validate usernames and I don't want people to put slashes in their usernames, it messes with URLs. I'm calling ereg($pattern, $username),…
Aistina
  • 12,435
  • 13
  • 69
  • 89
2
votes
1 answer

Why is POSIX collating-related bracketed symbol higher-precedence than backslash?

POSIX, aka "The Open Group Base Specifications Issue 7, 2018 edition", has this to say about regular expression operator precedence: 9.4.8 ERE Precedence The order of precedence shall be as shown in the following table: ERE Precedence (from…
aghast
  • 14,785
  • 3
  • 24
  • 56
2
votes
1 answer

Why do several Linux distros ship mawk by default even though it is not POSIX compliant?

mawk is not POSIX compliant because it does not support POSIX EREs. To be precise, it does not support named character classes like [[:space:]] within its EREs, which are part of POSIX EREs. Both GNU awk and BusyBox awk do not seem to have this…
2
votes
1 answer

regular expression POSIX problem on postgresql

I want to delete all 2 letter words in a string with several words. I came up with this solution : SELECT regexp_replace('UN DE DA ','\s{1}[A-Z]{2}\s{1}',' ','g'); SELECT regexp_replace('UN DE DA ','^[A-Z]{2}\s{1}',' ','g'); SELECT…
loic_midy
  • 103
  • 4
2
votes
3 answers

POSIX ERE Regular expression to find repeated substring

I have a set of strings containing a minimum of 1 and a maximum of 3 values in a format like this: 123;456;789 123;123;456 123;123;123 123;456;456 123;456;123 I'm trying to write a regular expression so I can find values repeated on the same…
Artemio Ramirez
  • 1,116
  • 1
  • 10
  • 23
2
votes
1 answer

Does bash operator =~ respect locale?

Does bash operator =~ as described in the Conditional Constructs section of the bash manual respect locale? The documentation alludes to it using POSIX extended regular expressions: the string to the right of the operator is considered an extended…
wich
  • 16,709
  • 6
  • 47
  • 72
2
votes
1 answer

PCRE to POSIX assistance

I need to extract the profile for these syslog entries. May 11 09:35:59 server-0548 ea_appserver: env=ACPT profile=product_api java[31185]: 2017-05-11 09:35:59,210 server-0548 org.hibernate.internal.SessionFactoryImpl ServerService Thread Pool --…
Naveen
  • 23
  • 3
2
votes
1 answer

POSIX extended Regex - contain not X but Y (std::regex c++11)

Question explanation I have been trying to write a regex to pass for exactly this format: "bob likes poo - whatever(&T(R)*HP#" " \t \t bob likes poo - *^RFVOG(IBHUO)B" but fail on: "//bob likes poo - GV*(GF*(" "# \t bob likes poo - OHG(G(*" …
Infogeek
  • 93
  • 1
  • 8
2
votes
1 answer

Unix find not respecting regex

I'm trying to do a simple find in my /var/log directory to find all syslog files that are not zipped. What I have so far is the regex: syslog(\.[0-9]*)?$ So this would find syslog, syslog.1, syslog.999, etc and skip over the gzipped logs like…
Kenny Worden
  • 4,335
  • 11
  • 35
  • 62
2
votes
2 answers

POSIX regular expression with extended syntax not matching where it should

I am trying to use POSIX regex in C, but it's not working. Here's my code: int regi(char *c, char *e) { regex_t regex; int reti = regcomp(®ex, e, 0); reti = regexec(®ex, c, 0, NULL, 0); if(!reti) return 1; return…
neby
  • 103
  • 1
  • 2
  • 9
2
votes
1 answer

Posix regex matching in C... Full match anomaly?

So my current homework is to implement a DBMS-like system in C, and I've decided to use the linux POSIX regex matching library. I'm writing toy codes to learn stuff, and this is my testing for the "command parsing" part of the DBMS. The post is a…
DVNO
  • 163
  • 2
  • 6