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
0
votes
1 answer

stripping out (ascii armored) PGP blocks in text file

given a file formatted as markdown occasionally interspersed with blocks of PGP, how can I strip out the PGP blocks using standard linux tools in a shell script? The file looks like this gist (I had to create a gist because of formatting issues)
code_monk
  • 9,451
  • 2
  • 42
  • 41
0
votes
3 answers

RegEx skip word

I would like to use regular expressions to extract the first couple of words and the second to last letter of a string. For example, in the string "CSC 101 Intro to Computing A R" I would like to capture …
IBWEV
  • 11
  • 1
  • 6
0
votes
2 answers

Bash: regular expressions within backticks

I have a file called "align_summary.txt" which looks like this: Left reads: Input : 26410324 Mapped : 21366875 (80.9% of input) of these: 451504 ( 2.1%) have multiple alignments (4372 have >20) ...more text.... ... and…
D. Kazmin
  • 1
  • 2
0
votes
2 answers

How to find files with text started with

I tried to use find ./ -type f -name '*.php' -exec grep -slE '^asdasd' {} \; and find ./ -type f -name '*.php' -exec pcregrep -l '^asdasd' {} \; But this commands found files, where 'asdasd' in beginning of lines, not of all text, for…
0
votes
2 answers
0
votes
3 answers

Find and replace wildcard that spans across lines?

I would like to input some text like this: foo stuff various stuff could be anything here variable number of lines bar Stuff I want to keep More stuff I want to Keep These line breaks are important and get out this: foo teststuff bar Stuff I…
Stonecraft
  • 860
  • 1
  • 12
  • 30
0
votes
1 answer

How can I extract URLs from html content with ruby regexp?

Lets go directly with an example since it is not easy to explain:
  • 0
    votes
    1 answer

    grep and return line continuations?

    I want grep to return results through line continuations, ie input file like: $ cat input.txt abba \ jjjj \ nnnn $ grep "abba ?" input.txt abba jjjj nnnn I can't seem to get it working.
    user318904
    • 2,968
    • 4
    • 28
    • 37
    0
    votes
    1 answer

    Deleting multiple lines from recursive pcregrep search

    In the header of every file in my project I have a block of comments that were generated by VCC with revision history for the file. We have moved away from VCC and no longer want to have the revision history in the file since it is obsolete. I…
    zumost
    • 1
    0
    votes
    3 answers

    Multiline pattern with one line of any content included

    I need to count the occurance of a multiline pattern of 3 lines in a htm file. The problem is that I have a fix content in line 1 and 3, however the content of line 2 is not fix, it can change (the file is a log). Here's an example of what I…
    McEdy
    • 3
    • 2
    0
    votes
    2 answers

    Matching 3+ Title Case Word in a single pcre expression

    I am looking for a single pcre (ver. 3.85) compatible regular expression that matches a string composed of three or more title case words but does not match any string containing words starting with lower-case letter. E.g.: "Gaius Julius Caesar"…
    George JL
    • 29
    • 5
    0
    votes
    3 answers

    Matching multiline string at command line: return certain line if pattern matches, otherwise return empty string

    The output of a command I have takes on the following form when it is a "success": / > ------- ABC123 / > It's possible for this command to emit something like this, though (a "failure"): / > ------- ABC123 ------- DEF456 ------- Hello…
    2rs2ts
    • 10,662
    • 10
    • 51
    • 95
    -1
    votes
    1 answer

    regex to search pattern and output multiple lines until another pattern

    I have a log file, where every log follows a pattern: Date [FLAG] LogRequestID : Content The Content part of each log might span multiple lines. Given a LogRequestID, I need to search for all occurrences, and get the entire log. I need this to be…
    gitmorty
    • 263
    • 1
    • 2
    • 8
    -2
    votes
    1 answer

    grep -P to find lines containing exactly n A's followed by exactly n B's

    Is it possible to write a grep -P (PCRE) command that prints the lines containing only A and B such that there are exactly n A's followed by exactly n B's and no other characters. Such that these are valid…
    -2
    votes
    3 answers

    regular expression to find the first occurance of a number from a given keyword

    I have a string "ZTFN00 identification number is 89320394 and mobile number is +918017828848" and I want to identify the first occurrence of a number (89320394 in this case) from the keyword ZTFN. Also, the expression shall not return 00 with the…