Questions tagged [pcregrep]

pcregrep searches files for character patterns, in the same way as other grep commands do, but it uses the PCRE regular expression library to support patterns that are compatible with the regular expressions of Perl 5.

76 questions
1
vote
0 answers

pcregrep multiline SQL match

I'm trying to match following multiline SQL code with pcregrep: create table work.W4XLP0D as select distinct Name, ('ABCD') as xxx length = 4 from &SYSLAST where Name='Alfred' ; I wanna match distinct and…
1
vote
1 answer

Get specific lines from text file to another text file

I have a plain text file with many lines, I am trying to get only the lines that start with |V| and runtime What I have tried: sed -e '/^\(runtime\|\\|V\\|\)/p' test.txt > test.out.txt sed -e '/^(runtime\|\\|V\\|)/' test.txt > test.out.txt sed -e…
Drew
  • 1,171
  • 4
  • 21
  • 36
1
vote
1 answer

Get a block from an XML file using data from a source file

I revamped this question since I've been reading a bit on XML. I have a file source file that contains a list of AuthNumbers. 111222 111333 111444 etc. I need to search for the numbers in that list and find them in a corresponding XML file. In…
mvasilakis
  • 13
  • 4
1
vote
1 answer

Multiline regex - how to skip lines to the end of last match

So for example we have the following in a file: START OF NEW LOG ENTRY first line second line KEYWORD third line START OF NEW LOG ENTRY first line second line third line etc... (this file goes on in this manner for a long time) ... I require to…
Lost Crotchet
  • 1,270
  • 12
  • 17
1
vote
0 answers

Why is pcregrep faster than grep?

I have some large text file(3 GB rails log file) on a centos os with a corrupted byte in this text file. When trying to search some pattern using grep, it runs indefinitely and I have to close it, however with pcregrep it takes less than a minute,…
user1011792
1
vote
0 answers

What IFS should I use in my BASH for loop if my input command arguments are multiple lines?

I want to store each single, complete, multiline result of a pcregrep into a variable for each iteration of a for loop. Ex: for a in $(pcregrep -Moh 'regex_that_spans_multiple_lines'); do blah blah done However, I'm not sure what IFS I should use…
Nolan
  • 363
  • 2
  • 10
1
vote
1 answer

Why does this regular expression match in pcregrep but not within my c++ code?

I have a regex that works perfectly with pcregrep: pcregrep -M '([a-zA-Z0-9_&*]+)(\(+)([a-zA-Z0-9_ &\*]+)(\)+)(\n)(\{)' Now I tried to include this regex in my C++ code but it does not match (escapes included): char const *regex =…
JohnnyFromBF
  • 9,873
  • 10
  • 45
  • 59
1
vote
1 answer

Convert string containing wildcards to regexp

I need to convert string containing wildcards with a regexp. For example, if I have an input string like below: ab*dd*c This means ab(any number of any characters)d(any number of any characters)c Where any character is any alphanumeric…
Heghine
  • 435
  • 3
  • 15
1
vote
1 answer

How to check long files with repeated strings using pcregrep

It's my first post here, it's great place and it helps me a lot ! So I'm using pcregrep and I want to catch files with my pattens. I'm using variable for regex like: test="<\?php\n.*. = Array\(('.'=>'.', ){20,}.*\);\nfunction .*\(.*,…
1
vote
1 answer

pcregrep matching stop at 1st occurrence

I am implementing a multiline search in UNIX using 'pcregrep'. I want the matching to stop at the 1st occurrence. e.g. if i have below text in a file: mynameishin hahahain internetin fdhsufsdhuiain djbssdvbsbsduiain sduigsyubsuvasdyivsyifvasin I…
sacs0406
  • 19
  • 1
1
vote
2 answers

convert pcregrep command in awk or sed

I have a multiline matching pcregrep command that I'd like to convert into an awk or sed command, because I need it on a machine where pcregrep is not available (OS X). Original command: ifconfig -a | pcregrep -M…
KaZ
  • 13
  • 3
1
vote
2 answers

Define given number of tabs in Regex lookbehind (pcregrep)

I use pcregrep to find patterns over multiple-lines in html code. I try to match something that looks similar to this: sometext The space between sometext and the beginning of the line equals…
joaoal
  • 1,892
  • 4
  • 19
  • 29
0
votes
0 answers

How to combine non-adjacent groups without using branch resets or capturing inside lookarounds?

Suppose I have the following text: # Should match - [ ] Some task - [ ] Some task | [[link]] - [ ] Some task ^abcdef - [ ] Some task | [[link]] ^abcdef - [ ] ! Some task - [ ] ! Some task | [[link]] - [ ] ! Some task ^abcdef - [ ] ! Some task |…
Mihai
  • 2,807
  • 4
  • 28
  • 53
0
votes
0 answers

Loop pcregrep and get one match per index

i try to put all pcregrep matches in a loop but when i have two matches in one line or only the second match. I would like to loop it with one match per loop-index. this is what i have now but i just get the second match: pcregrep -o1 -r…
justcasper
  • 396
  • 1
  • 17
0
votes
2 answers

How to remove multi-line with multi-pattern, awk pcre2grep sed

I have this text file tittleofthis123 rescode11 depcode12 …