10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi all,
I want to extract rows with the pattern ALPHANUMERIC/ALPHANUMNERIC in the 2nd column.
I dont wan rows with more than 1 slash or without any slash in 2nd column.
a a/b
b a/b/c
c a/b//c
d t/y
e r
f /f
I came up with the regex
grep '\/$' file
a a/b
b a/b/c
d t/y (3 Replies)
Discussion started by: jianp83
3 Replies
2. 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
3. UNIX for Dummies Questions & Answers
I am trying to find patterns in files using grep -l -e. I specifically am searching for abc. I want any file that has abc in it, but not just the letters abc. I am searching for a pattern a followed by b followed by c. I have tried egrep -l and also I have tried the following:
grep -el... (2 Replies)
Discussion started by: newbie2010
2 Replies
4. Shell Programming and Scripting
Hi,
I've a logfile which i need to parse and get the logs depending upon the user input. here, i'm providing an option to enter the string which can be matched with the log entries.
e.g. one of the logfile entry reads like this -
$str = " mpgw(BLUESOAPFramework):... (6 Replies)
Discussion started by: butterfly20
6 Replies
5. Shell Programming and Scripting
I need a way to extract data from
X 4T Solution 21 OCT 2011 37 .00
to account 12345678 User1 user2
X 4T Solution Solution Unlimited 11 Sep 2009 248 .00
to account 87654321 user3 user4
I need it to extract 'X' '37.00' and account number 12345678.
I have extracted above stuff... (3 Replies)
Discussion started by: chakrapani
3 Replies
6. 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
7. Shell Programming and Scripting
Hi Expert,
Could you please explain why below two perl code get different result?
Thanks a lot.
sub test{
return (2,3,4,5,6,3,4,50);
}
($a,$b)=(test); # 3,6
($a,$b)=test; # 2,3 (2 Replies)
Discussion started by: summer_cherry
2 Replies
8. Shell Programming and Scripting
Hi folks,
Lets say I have the following text file:
name, lastname, 1234, name.lastname@test.com
name1, lastname1, name2.lastname2@test.com, 2345
name, 3456, lastname, name3.lastname3@test.com
4567, name, lastname, name4.lastname4@test.com
I now need the following output:
1234... (5 Replies)
Discussion started by: domi55
5 Replies
9. Shell Programming and Scripting
I'm using the URL Regex feature of Squid for allowing sites via a list of regex strings to match allowed domains. The regex was actually copied from our previous proxy solution and it seemed to "just work". But, we've recently discovered that some domains (likely due to virtual hosts or host... (2 Replies)
Discussion started by: deckard
2 Replies
10. Shell Programming and Scripting
I'm trying to use the following command to do a batch find and replace in all commonly named files through a file hierarchy
find . -name 'file' |xargs perl -pi -e 's/find/replace/g'
which works fine except for a substitution involving parenthesis.
As a specific example I'm trying to sub... (3 Replies)
Discussion started by: Jeffish
3 Replies
Text::Glob(3) User Contributed Perl Documentation Text::Glob(3)
NAME
Text::Glob - match globbing patterns against text
SYNOPSIS
use Text::Glob qw( match_glob glob_to_regex );
print "matched
" if match_glob( "foo.*", "foo.bar" );
# prints foo.bar and foo.baz
my $regex = glob_to_regex( "foo.*" );
for ( qw( foo.bar foo.baz foo bar ) ) {
print "matched: $_
" if /$regex/;
}
DESCRIPTION
Text::Glob implements glob(3) style matching that can be used to match against text, rather than fetching names from a filesystem. If you
want to do full file globbing use the File::Glob module instead.
Routines
match_glob( $glob, @things_to_test )
Returns the list of things which match the glob from the source list.
glob_to_regex( $glob )
Returns a compiled regex which is the equivalent of the globbing pattern.
glob_to_regex_string( $glob )
Returns a regex string which is the equivalent of the globbing pattern.
SYNTAX
The following metacharacters and rules are respected.
"*" - match zero or more characters
"a*" matches "a", "aa", "aaaa" and many many more.
"?" - match exactly one character
"a?" matches "aa", but not "a", or "aaa"
Character sets/ranges
"example.[ch]" matches "example.c" and "example.h"
"demo.[a-c]" matches "demo.a", "demo.b", and "demo.c"
alternation
"example.{foo,bar,baz}" matches "example.foo", "example.bar", and "example.baz"
leading . must be explictly matched
"*.foo" does not match ".bar.foo". For this you must either specify the leading . in the glob pattern (".*.foo"), or set
$Text::Glob::strict_leading_dot to a false value while compiling the regex.
"*" and "?" do not match /
"*.foo" does not match "bar/baz.foo". For this you must either explicitly match the / in the glob ("*/*.foo"), or set
$Text::Glob::strict_wildcard_slash to a false value with compiling the regex.
BUGS
The code uses qr// to produce compiled regexes, therefore this module requires perl version 5.005_03 or newer.
AUTHOR
Richard Clamp <richardc@unixbeard.net>
COPYRIGHT
Copyright (C) 2002, 2003, 2006, 2007 Richard Clamp. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
File::Glob, glob(3)
perl v5.16.3 2011-02-22 Text::Glob(3)