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,…
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…
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,…
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),…
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…
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…
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…
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…
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…
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 --…
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(*"
…
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…
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…
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…