06-30-2011
Quote:
Originally Posted by
Scrutinizer
(?:regex) is a non-capturing group as opposed to (regex), but it is not supported by bash I think. It seems to work in a recent version of ksh93 though...
Thanks.
Do you have any idea how I can accomplish the same thing in bash?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
i want to match a string using perl that has got 5 pluses(+++++).
i am using a function for this.
$str1="+++++";
check($str1,"\\+");
sub check{
$str1=$_;
$str2=$_;
if($str1=~m/^$str2{5}$/){
print "Correct.\n";
}else{
print "Wrong..\n";
... (6 Replies)
Discussion started by: deepakpv
6 Replies
2. Shell Programming and Scripting
Hi,
I am trying to grep for the following type of string from a document given below:
12637 1239 3356 12956 7004 7004 7004 13381 13381
*> 12.0.1.63 0 7018 21872 ?
* 208.51.134.254 53 0 3549 7018 21872 ?... (1 Reply)
Discussion started by: Legend986
1 Replies
3. UNIX for Dummies Questions & Answers
Can anyone give the detailed explanation on regex search
i want to know the use of regex in sed and awk also......
the operators like ^,.,* ....etc i need it with some example.....kindly help on this.
I gone through the man pages also..but i was not clear......... (1 Reply)
Discussion started by: sivakumar.rj
1 Replies
4. Shell Programming and Scripting
I would like to search strings composed by only one type of charachter for example
only strings composed by the charachter 'b'
is it right?
$egrep '\<(b+)+\>' filename
Could be there some side effects?
Regards. (1 Reply)
Discussion started by: and77
1 Replies
5. Shell Programming and Scripting
I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly:
if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies
6. UNIX for Advanced & Expert Users
Can someone tell me what is going with this expression :%s/<C-V><C-M>/.
Is there a way to get a more useful message if the carriage return has been deleted?
http://objectmix.com/editors/149245-fixing-dos-line-endings-within-vim.html#post516826
Why does this expression work for... (1 Reply)
Discussion started by: cokedude
1 Replies
7. UNIX for Dummies Questions & Answers
I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header.
In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies
8. Shell Programming and Scripting
I am not a big expert in regex and have just little understanding of that language.
Could you help me to understand the regular Perl expression:
^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{
------
This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies
9. UNIX for Beginners Questions & Answers
Here i am writing a script to check&display only the valid mail address from a file
echo "Plz enter the Target file name with path"
read path
if
then
echo "The valid mail address are:"
email=$(grep -E -o "\b+@+\.{2,6}\b" $path )
echo "$email"
fi
The file contains the data like this:... (6 Replies)
Discussion started by: Meeran Rizvi
6 Replies
10. Shell Programming and Scripting
I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works:
LOCAL_CONFIG
#
Kcheckaddress regex -a@MATCH
+<@+?\.++?\.(us|info|to|br|bid|cn|ru)
LOCAL_RULESETS
SLocal_check_mail
# check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies
LEARN ABOUT SUSE
encode::alias
Encode::Alias(3pm) Perl Programmers Reference Guide Encode::Alias(3pm)
NAME
Encode::Alias - alias definitions to encodings
SYNOPSIS
use Encode;
use Encode::Alias;
define_alias( newName => ENCODING);
DESCRIPTION
Allows newName to be used as an alias for ENCODING. ENCODING may be either the name of an encoding or an encoding object (as described in
Encode).
Currently newName can be specified in the following ways:
As a simple string.
As a qr// compiled regular expression, e.g.:
define_alias( qr/^iso8859-(d+)$/i => '"iso-8859-$1"' );
In this case, if ENCODING is not a reference, it is "eval"-ed in order to allow $1 etc. to be substituted. The example is one way to
alias names as used in X11 fonts to the MIME names for the iso-8859-* family. Note the double quotes inside the single quotes.
(or, you don't have to do this yourself because this example is predefined)
If you are using a regex here, you have to use the quotes as shown or it won't work. Also note that regex handling is tricky even for
the experienced. Use this feature with caution.
As a code reference, e.g.:
define_alias( sub {shift =~ /^iso8859-(d+)$/i ? "iso-8859-$1" : undef } );
The same effect as the example above in a different way. The coderef takes the alias name as an argument and returns a canonical name
on success or undef if not. Note the second argument is not required. Use this with even more caution than the regex version.
Changes in code reference aliasing
As of Encode 1.87, the older form
define_alias( sub { return /^iso8859-(d+)$/i ? "iso-8859-$1" : undef } );
no longer works.
Encode up to 1.86 internally used "local $_" to implement ths older form. But consider the code below;
use Encode;
$_ = "eeeee" ;
while (/(e)/g) {
my $utf = decode('aliased-encoding-name', $1);
print "position:",pos,"
";
}
Prior to Encode 1.86 this fails because of "local $_".
Alias overloading
You can override predefined aliases by simply applying define_alias(). The new alias is always evaluated first, and when necessary,
define_alias() flushes the internal cache to make the new definition available.
# redirect SHIFT_JIS to MS/IBM Code Page 932, which is a
# superset of SHIFT_JIS
define_alias( qr/shift.*jis$/i => '"cp932"' );
define_alias( qr/sjis$/i => '"cp932"' );
If you want to zap all predefined aliases, you can use
Encode::Alias->undef_aliases;
to do so. And
Encode::Alias->init_aliases;
gets the factory settings back.
SEE ALSO
Encode, Encode::Supported
perl v5.12.1 2010-04-26 Encode::Alias(3pm)