Questions tagged [pcre]
Perl compatible regular expressions syntax and library
29 questions
3 votes
2 answers
214 views
Syntax Error on ssed for Regex Subroutine definitions
I'm stuck with this error without clue or reference how to solve it: I have this list on text.txt Angie Apple Angie Banana Angie Tomato Angie Peach Angie Onion I'm running substitution through ssed (...
4 votes
0 answers
6k views
In journalctl internal grep, is it possible to specify option to only output matched pattern?
I have the following journal messages: $ journalctl _COMM=kwin_wayland -o cat --since "-10s" ... kwin_screencast: Dropping a screencast frame because the compositor is slow kwin_screencast: ...
1 vote
2 answers
193 views
XMLERR: Element '=").*?(?=")</regex' not closed while using lookaround
I am trying to use lookaround element in PCRE2 regex for Wazuh tool, i need to match strings which are in double quotes and made the below regex however it looks its picking up "<" ...
0 votes
1 answer
322 views
Is possible to discard outer brackets in regex and consider inner bracket inside?
I have many patterns with bracket enclosure, I made a regular expression where is not considering brackets and just only what is inside/between them, but exists a problem when the text within brackets ...
1 vote
4 answers
785 views
Find lines with first word containing a certain set of letters
The input file exists out of lines containing multiple 10-letter combinations: NGNAEAREAX EAHVSELYCI FNWGNLACQM AWKLRMDHIT PRYMFNYMVM NCNREDEEEQ EAHVSELYCI FNWGNLACQM AWKLRMDHIT PRYMFNYMVM I need a ...
3 votes
2 answers
1k views
Rename file with the rename tool - moving around square brackets
Rookie question. Following this answer Move last part of filename to front, I'm trying to do the same, except all files in my case contains square brackets. What I want is to move the title to the ...
3 votes
3 answers
1k views
Extract text starting at specific category header to next category header from a text file
I have a TOML file in the following format (categories may have any name, the sequential numbering is just an example and not guaranteed): [CATEGORY_1] A=1 B=2 [CATEGORY_2] C=3 D=4 E=5 ... [...
3 votes
5 answers
17k views
Matching Repeating Pattern Using Regex
Let's say I have a file like following 1,2,3-5,6 1,2,3-5,6, 1 1-3 1,2,3-,4,5-7 1,2,3-,4,5-7, 1,2,-3,4,5 1,2,-,3,4 1,2,,,3,4 ,1,2,3 Only combination of following rules should be considered as valid: ...
9 votes
1 answer
7k views
How to refer to matched groups in jq gsub?
Using jq, I want to search for a pattern via regex, and wrap the matched string with something like <div> tags $ echo "\"This is a valid json file"\" | jq '. | gsub("...
7 votes
5 answers
18k views
Local installation of pcre2 not detected while installing R 4.0.4 from source
I am trying to do a build and local install of R 4.0.4 on Red Hat Linux 6.8. There were several unmet dependencies which I resolved by doing local installations (following the procedure in this). ...
0 votes
1 answer
56 views
grep nonascii without pcre
I want to grep nonascii characters from a lot of .gz files. However the below does not work on CentOS 7.6 (GNU grep v2.20) $ zcat yyyy/yyyymmdd/filname.yyyymmdd.gz | grep --color='auto' -P -n "[\...
2 votes
1 answer
258 views
Can I change the regex engine used to search in `less`?
I would like to use a perl compatible regex engine in the less command line utility. Is that possible?
1 vote
2 answers
693 views
Advanced regex: Can't figure a case where (?R) recursive regex can be used
Is anyone here can explain a case where the recursive Perl/PCRE regex (?R) can be helpful ? I read https://regular-expressions.mobi/recursebacktrack.html?wlr=1 https://perldoc.perl.org/perlre.html#(%...
3 votes
4 answers
9k views
Help with this non-capturing group with grep?
I am new to GNU/Linux and regex. Recently I've been playing around trying to get to grips with regex. So far I feel I've got a pretty solid foundational understanding. I'm digging PCRE at the moment. ...
0 votes
1 answer
350 views
build apache on linux server
I have downloaded pcre from https://ftp.pcre.org/pub/pcre/pcre2-10.34.tar.gz and extracted it to /usr/local/lib when I run ./configure --with-included-apr --with-pcre=/usr/local/lib/pcre2-10.34 I ...