Regular expressions are a means of matching a pattern of characters within a string.

learn more… | top users | synonyms (1)

0
votes
1answer
259 views

python regex equivalent of kwrite [ ]+ and [0-9]+

I've never been good at regular expressions. When ever I read about them, I sort of get a headache, get up from my desk, and forget what I'm doing. Attention difficulties. But when I finally started ...
0
votes
1answer
834 views

Curl and grep html text

Is there a way to grep html text from a curl request and output grab the value that is between two html tags? More specifically the input value of a form?
0
votes
2answers
17 views

How to search parenthesis by ack

I want to search for a parentheis ( using ack, but neither using ( nor \( worked. The first one ("(") is recognized as a multiple line command. The second one ("\(") is treated as an invalid regular ...
0
votes
1answer
31 views

Regex for matchng anything between parenthesis

I have the following regex so far: printf "this is (test.com)\n" | grep -Po '(?<=\().*(?=\))' The above regex will print the desired output, which is test.com As far as I am adding new ...
0
votes
1answer
24 views

Coordinates X237595Y81600 to X2375Y8160

I have create a gerber file and it has lines inside which look like this: X90095Y15350 X100095Y15350 X110095Y15350 X120095Y15350 X120095Y25350 X110095Y25350 X100095Y25350 X90095Y25350 X80095Y25350 ...
0
votes
1answer
26 views

is there a way to see a listing of packages ONLY from Debian-experimental?

I am on Debian testing/Jessie and I have debian-experimental as well as in my /etc/apt/sources.list. So I am looking to list packages in two ways :- a. List all the packages which are in ...
0
votes
2answers
247 views

Shell script to add or replace block of text?

I'm looking for a shell script (Bash) that adds or replaces copyright text at the beginning of the file (for .c and .h files). It should search and add or replace the copyright text block for all the ...
0
votes
1answer
46 views

combining grep ignore and matches

I would like to grep a file to find all instances of the text fn1 that don't have the word call in front of it and print out four lines before and after the matches (even if the surrounding lines have ...
0
votes
2answers
93 views

Bash regex string manipulation bug

I have an issue with bash and its regex match ability that I for now think is a bug in bash but could also be me having missed something obvious. I hope it is the latter. I have made this function in ...
0
votes
1answer
57 views

No output from grep -P 'com\K\w+'

I have a source file saved off the internet which has various links I want to pull data from. For example https://blahblah.com/uniquetext I'm using grep -oP 'com\K\w+' source.txt > list.txt ...
0
votes
2answers
47 views

How to make my regular expression accept zeroes in the input?

I wrote a regex that accepts numbers between 0 and 999,999,999,999.99. Commas are optional, but, still should accept value not higher than 999999999999.99. I wrote one, but, there are two flaws in it. ...
0
votes
1answer
31 views

regexp in find to locate only

I have csv file (products.csv) with product numbers $ cat products.csv | head -3 2.20 2.21 2.22 in another directory I have thousands of product images in subdirectories. I need to locate product ...
0
votes
1answer
54 views

How can I parse my String using regular expression to get only certain number of matches? [closed]

I am currently using this following regular expression to split my String into groups. ^([a-zA-Z0-9]*)(\[([a-zA-Z0-9=]*)\]){0,1}@([a-zA-Z0-9]*)$ Pty[R=4]@ID I am getting four groups 1) Pty 2) ...
0
votes
2answers
257 views

How to match date in Perl — assuming UNIX regex is the same as Perl's

I want to match dates of the form Monday May 26 My attempt to do this is the following: /(.*day Jan.*|Feb.*|Mar.*|Apr.*|May|Jun.*|Jul.*|Aug.*|Sep.*|Oct.*|Nov.*|Dec.* [1-31])/ The regex form in ...
0
votes
4answers
92 views

Print text between tags (inclusive) if certain text is found

I've got a task to extract data from several Apache servers. The task is to print out: <Directory ...> ... </Directory> where +ExecCGI is located within. Let me give an example to ...
0
votes
1answer
224 views

bash using grep and sed

This is for our weekly prac, no marking or grade (we don't even get the answers!) I'd really appreciate it if anyone has the time to help explain this exercise to me, as I'm trying to get this work ...
0
votes
1answer
174 views

How many times does the same character occur twice in a row

My task is using grep to find how many times the same character occurs twice in a row. I was thinking about something like this but it isn`t working grep '[a-zA-z]{2}' *.txt | wc How can achieve ...
0
votes
2answers
292 views

bash script, printing multiple lines that matching to a specific patern

I have a log file and I'm making a script to do some actions. An action is to print a specific area of the log. Every block at the log starts with a specific time stamp and inside the block may have ...
0
votes
1answer
103 views

(e)grep and atomic grouping [comprehension question]

I am trying to understand the correct use of »atomic grouping« a.k.a. »independent subexpressions« a.k.a. »non-backtracking subpattern« [this are the terms I found ...
0
votes
1answer
970 views

How to highlight the whole log-line in color with multitail

I'm trying to use multitail to tail logs with color highlights. I defined a custom color scheme in multitail.conf, something like this: colorscheme:my-color cs_re:red:^\[E cs_re:yellow:^\[W ...
0
votes
2answers
213 views

Difference in regular expression handling between Perl, Kikki, and Kodos

#!/usr/bin/perl $mystring = "[2004/04/13] The date of this article."; if($mystring =~ m/(\d+)/) { print "The first number is $1."; } Perl returns 2004, but Kiki and Kodos return /04/. Why ...
0
votes
0answers
11 views

use php variables for awk regex commands [duplicate]

trying to implement autosuggest using php. autosuggest list generated using awk $input= $_GET["term"]; $suggest=array(); exec('awk \'BEGIN{FS=","}/.$input./{print $2,"-cost-",$1}\' ...
0
votes
1answer
26 views

Printing out range of a pattern with awk

Im trying to print out a section of a txt file using awk. Basically I want to print out the paragraph in the a txt file that begins with certain words all up to a blank line.Here's what I have so far: ...
0
votes
0answers
30 views

SED and regex expressions… addr1 and addr2

How can I use sed to match 'addr1' and reuse it again in 'addr2' field? #Ex.: echo "12a34" | sed 's/a/#bcd/g' # 12abcd34 #\# = match addr1
0
votes
1answer
25 views

How to change a single line in multiple files [duplicate]

I have ~750 .php files in the same directory that contain the line include("path/to/file.php"); I would like to change this line in every file to require_once("path/to/file.php"); What would be ...
0
votes
1answer
31 views

Sed with angle brackets

This works sed 's/[[:space:]]*<default>false/XXX/' Why does prepending a > make it fail sed 's/>[[:space:]]*<default>false/XXX/' escaping the > does not help either. In ...
0
votes
2answers
74 views

sed to replace a word from a file with the contents of another file? [duplicate]

I have two files file1 & file2. Contents of file1: Text1 Text2 Text3 Contents of file2: Sample1 Sample2 Sample3 I would like to replace the word Text1 from file1 with the contents of ...
0
votes
2answers
40 views

How to make a script to move files with find and regex

Im trying to make a find regex script so i automaticly can copy files to specific directory. find . -regex "*test.*s01e([0-9][0-9]).*" -exec cp {} /storage/tv/test/s01/ \; Made this script, dont ...
0
votes
0answers
29 views

egrep for specified strings and newline

I receive a prespecified list of strings. In a number of textfiles (example below), I want to search for strings, that do not start with one of the strings in the list. From time to time, a blank link ...
0
votes
0answers
16 views

Oracle / sql : calculation one or more value within the same field

I want select statement to sum the amount of value 352+652+20+356 that come in the same filed without need PL/SQL . [{Name:"account:account_1"&Value:352&New:256&CreditLimit:0} ...
0
votes
2answers
44 views

2 consecutive digits using RegEx?

Is there a way to print words containing 2 consecutive digits divided with whitespace? Regardless of the input, is that possible? If yes, please share your ideas.
0
votes
0answers
66 views

how to exclude range of numbers using regular expression

I'm trying to write a regular expression in order to cover all numbers starting with 1809 and excluding some ranges: Ranges needed to be excluded Starting with 1809 and followed by: ...
0
votes
0answers
19 views

To visualise look-behind in this Regex

I am using Regexr to visualise my regexes now. I need look-behind but Javascript does not support it, example code here. The project code base seems to be dependent Javascript (NodeJS) in Github. I ...
0
votes
0answers
75 views

Find & replace image URLs in one file from another file

I am trying to replace all the image source URLs in an HTML file from a list of URLs in a text file. File1.html <td class="MetadataRes" width="380px" colspan="2" style="border-top: 1px #336699 ...
0
votes
2answers
51 views

add bracket across numbers at only end of each line

I have a file having lines as: ram_reg_10/raja_reg_9/raghu_reg_8 abc_reg_4/bcd_reg_5 cad/pqr_reg_91 I want to convert string "_reg_number" into [number] at only last of every line in vi ...
0
votes
3answers
110 views

Finding and replacing text inside awk block

I want to find and replace a value inside awk block. Here is a sample input file to my script P1 10,9:11/18013013582 ,10:1 ,167:0 ,487:5/E.164 11,9:15/310410532169026 ,10:60 ,167:0 ,487:4/IMSI ...
0
votes
0answers
14 views

Using regex in locate [duplicate]

I would like to search for both words pdf and hack in all filenames and their paths. The order of the two words doesn't matter. I use the command locate with a regex pattern: locate --regex ...
0
votes
1answer
189 views

Search for pattern across multiple files and replace a sub-part in all occurences

I am helping a friend with her thesis written in LaTeX and I need a quick solution for a "search and replace". Using a terminal in Linux, how can I find the following pattern: \caption{*\cite{*}} ...
0
votes
1answer
68 views

How can I use gsub with a pattern? And how to tell it which file to awk?

I've read here that I can replace the values of all columns containing a particular text using awk -F'\t' -vOFS='\t' '{ gsub("CC", "C", $1) ; gsub("AA", "A", $1) ; print }' But where do I tell awk ...
0
votes
2answers
1k views

what is “an invisible whitespace character that takes up space”

One can look up Unicode Characters with Regular Expressions. On Jan Goyvaerts website I found a RegExp whose meaning I don't understand : \p{Zs} or \p{Space_Separator}: a whitespace character that ...
0
votes
1answer
563 views

Remove a block of lines between two patterns [duplicate]

Possible Duplicate: Show only text between 2 matching pattern In a bash script using sed how can I remove a block of lines beginning with -pattern a- and ending with -pattern b- where the ...
-1
votes
2answers
3k views

Meaning of asterisk (*) in grep

[USERNAME@host ~] echo -e 'prdxxx\ndadxxx' | grep "da*xxx" prdxxx dadxxx [USERNAME@host ~] echo $SHELL /bin/bash [USERNAME@host ~] dpkg -l | grep -iw bash ii bash ...
-1
votes
2answers
197 views

How to remove a newline character in a particular line through perl?

I want to remove a newline character in a particular line through perl one-liner command. Input: 1407233497,1407233514,bar 1407233498,1407233515,foo mingstats&fmt=n 1407233499,1407233516,foobar ...
-1
votes
4answers
942 views

How to exclude directories from `ls -R` output?

If ls -aR | grep ":$" returns ./.hiddendir2: ./dir1: ./dir3: ./dir3/.hiddendir4: then how can you update the pattern given to grep so that you only get ./dir1: ./dir3: (note that the last ...
-1
votes
2answers
103 views

How to get `expr match` to extract colon-delimited key-value pair?

Given: myvar="present-value: 1", I'd expect expr match "$myvar" '\([0-9]\)' to output 1. However, instead it outputs blank and exits with a non-zero status code indicating no match. How can I get it ...
-1
votes
3answers
216 views

Removing second colon

Trying to create a simple script that lists mass mailing by the queue number that appears in /var/log/maillog. I'm starting off with this: [root@ditirdlns01 ~]# lsMails(){ grep -i ...
-1
votes
1answer
268 views

Regular expression to mask credit card digits in a file

What is the most simplest way to mask all numbers but the last 4 digits of a credit card number in a file using sed. Using egrep with the following regular expression we can find numbers of Visa, ...
-1
votes
2answers
102 views

Regular expressions in a shell [duplicate]

I have two questions about using regular expressions inside a shell. 1. Use of * According to wikipedia page on regular expressions: *: The asterisk indicates there is zero or more of the ...
-1
votes
1answer
302 views

extracting ip address from a file [closed]

I'm trying to extract all the IP address from a file. FILE *>i85.95.2.160/29 172.16.24.4 0 200 0 64515 4445 15412 i *>i85.112.80.0/28 172.16.24.4 0 200 ...
-1
votes
1answer
482 views

How to “grep -v” private/broadcast IPv4 addresses?

time nmap -n -iR 0 -sL | cut -d " " -f 5 | egrep -v "^10.*|^172.[16\-32].*|^192.168.*|^[224\-255].*" > RANDOM-IPS.txt so the important part is: egrep -v ...