Further to Scrutinizer's points, you may want to simplify the regex. The backreference is not used, so the round brackets may be discarded. "\w" takes care of "a-zA-Z0-9_". The dot (".") loses its special meaning inside a character class. The dash ("-") need not be escaped inside the brackets, rather, putting it at the end is enough to avoid it from being expressed as a range character. And finally, add the "$" inside the character class if you want to match it.
Here's the updated regex -
tyler_durden
Last edited by durden_tyler; 06-16-2010 at 09:50 AM..
How to emulate grep -o option in perl.
I mean to print not all line, only the exact match.
echo "2A2 BB" | perl -ne 'print if /2A2/'
2A2 BB
I want to print only 2A2. (2 Replies)
Hi
By using select clause I'm trying to pull out the rows to a variable.
If the variable has 0 row(s) selected then i'm printing some text message
else printing some other text message
if($xyz =~ m/0 row/)
{
print "0 rows ";
}
else
{
print " There are rows";
}
By my problem... (4 Replies)
I am trying to match a pattern exactly in a shell script. I have tried two methods
awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath
perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath
Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
I have a file that contains the 2 following lines (from /proc/mounts)
/dev/sdc1 /mnt/backup2 xfs rw,relatime,attr2,noquota 0 0
/dev/sdb1 /mnt/backup xfs rw,relatime,attr2,noquota 0 0
I need to match the string in the second column exactly so that only one result is returned, e.g.
> grep... (2 Replies)
Hello,
My requirement is to iterate over all the lines of a file and compare them with a word and perform some operations if exact match is found.
For the snippet below, it works even if contents of line include "diff" and "diff:". I want it to work only if it is exactly "diff" and is not... (2 Replies)
i have a script in which i need to skip comments, and i am able to achieve it partially...
IN text file:
{****************************
{test : test...test }
Script:
while (<$fh>)
{
push ( @data, $_);
}
if ( $data =~ m/(^{\*+$)/ ){
}
With the above match i am... (5 Replies)
Hi,
I'm trying to match the front and back of a sequence. It works when there is an exact match (obviously), but I need the regex to be more flexible. When we get strings of nucleotides sometimes their prefixes and suffixes aren't exact matches. Sometimes there will be an extra letter and... (2 Replies)
Hi experts,
I have a file with regexes which is used for automatic searches on several files (40+ GB).
To do some postprocessing with the grep result I need the matching line as well as the match itself.
I know that the latter could be achieved with grep's -o option. But I'm not aware of a... (2 Replies)
Hi All,
We have this regex:\\*.*?(.600).*?.(LISTEN|ESTABLISHED)
OS = Solaris 10
The purpose of this regex is to match the ports in output of "netstat -an" and report if any ports between 6000-6009 are getting used. The only problem is if I have something like this (sample output as... (6 Replies)
I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output.
$1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies
LEARN ABOUT DEBIAN
postal-list
postal-list(1) Postal postal-list(1)NAME
postal-list - program to show how postal expands user names
SYNOPSIS
postal-list user-list-filename conversion-filename
DESCRIPTION
This program shows the expansion that the postal program uses on email addresses. This can be used to make sure that you're configuration
files do what you expect them to, and can also be used to produce a list of user-names for an account creation script (in case you want to
create a million test accounts in a conveniant fashion).
The user-list-filename is the name of a file which contains a list of user's email addresses. This can be just user-names or fully quali-
fied email addresses.
The conversion-filename parameter will be the name of a file containing the conversions to apply to email addresses. Each line in the file
can either be a comment (starting with "#") or is to contain two parameters. The first parameter is the regular expression. For each
email that is to be sent a randomly selected user-name will be checked against all regular expressions, the first match will determine the
translation that is to be applied. The translation will be the second parameter on the line. It will contain a number of "." characters
specifying characters in the name that are not to be translated. To specify the translations a range of characters can be specified inside
square brackets. For example to have every address starting with "a" have a character from "01234567890abc" as it's second character and a
character from "xyz" as it's third character you would have the following: ^a .[0-9abc][xyz]
RETURN CODES
0 No Error
1 Bad Parameters
AUTHOR
This program, it's manual page, and the Debian package were written by Russell Coker <russell@coker.com.au>.
AVAILABILITY
The source is available from http://doc.coker.com.au/projects/postal/ .
See http://etbe.coker.com.au/category/benchmark for further information.
SEE ALSO postal(8),rabid(8),regex(7)russell@coker.com.au 0.70 postal-list(1)