perl regex help solved


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl regex help solved
# 1  
Old 04-06-2010
perl regex help solved

Hi there I have a list of mac addresses that are in this format


Code:
0100237D2136XX
0118A905599EXX
0118A9054E15XX
010003BAF1F3XX
0118A905599EXX
0100237D6522XX
010C53BAF1F3XX
010003BAF1F3XX
010C53BAF1F3XX

The 01 is at the beginning has been put on by my software, but the rest is the mac address

I want to use a perl regex to pull out only those that have the following first 8 characters, discarding the rest

0100237D
0118A905


Ive tried many different combinations but just cant get ti to work, am i doing something silly here?

Code:
        
        if ($MAC =~ /^01[01]{1}[08]{1}[2A]{1}[39]{1}[70]{1}[D5]{1}.*/ ) {
                print "$MAC\n";
        }

im probably getting a little confused with the {1} bit somewhere, could somebody advise me where im going wrong here

Cheers

---------- Post updated at 05:50 AM ---------- Previous update was at 05:48 AM ----------

Sorry, Please ignore, i managed to make a silly typo in my script

sorry about that

---------- Post updated at 05:51 AM ---------- Previous update was at 05:50 AM ----------

Sorry, Please ignore, i managed to make a silly typo in my script

sorry about that (the regex works just fine)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl REGEX help

Experts - I found a script on one of the servers that I work on and I need help understanding one of the lines. I know what the script does, but I'm having a hard time understanding the grouping. Can someone help me with this? Here's the script... #!/usr/bin/perl use strict; use... (2 Replies)
Discussion started by: timj123
2 Replies

2. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

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. Shell Programming and Scripting

?= in perl regex

Could anyone please make me understand how the ?= works below .. After executing this I am getting the same output. $string="I love chocolate."; $string =~ s/chocolate(?= ice)/vanilla/; print "$string\n"; (2 Replies)
Discussion started by: scriptscript
2 Replies

4. Shell Programming and Scripting

[Solved] Inserting a line beginning with regex

I have been trying to insert a line after a regex but I can't do it. Here is the code I am using: cat saved_doc SET type = type1 SET type = STORE = y /vol/san_e1 /vol/san_5 /vol/san_e9 /vol/san_e11 /vol/san_e12 /vol/san_e13 /vol/san_e14 /vol/san_e16 /vol/san_e17 /vol/san_e18... (4 Replies)
Discussion started by: newbie2010
4 Replies

5. Programming

Perl regex

Hi Guys I have the following regex $OSRELEASE = $1 if ($output =~ /(Mac OS X (Server )?10.\d)/); output is currently Mac OS X 10.7.5 when the introduction of Mac 10.8 output changes to OS X 10.8.2 they have dropped the Mac bit so i changed the regex to be (2 Replies)
Discussion started by: ab52
2 Replies

6. Web Development

[SOLVED] Regex with Apache RewriteRule

Hello Folks.... How you doing all ... Need your assistance with an Regex with apache rewriterule. This is what am doing... 1. Using Apache webserver as proxy server for multiple tomcats 2. Using IP filter with in apache using RewriteCondition and RewriteRule 3. Trying to specify in... (1 Reply)
Discussion started by: Lynx4DBA
1 Replies

7. Shell Programming and Scripting

Converting perl regex to sed regex

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

8. Shell Programming and Scripting

Perl regex

I have got numbers like l255677 l376039 l188144 l340482 l440700 l254113 to match the numbers starting with '13' what would be the regex =~/13(.*)/ =======>This is not working .... But for user123,user657 regex =~/user(.*)/ ========>works Thanks for help..!! (7 Replies)
Discussion started by: trina_1
7 Replies

9. Shell Programming and Scripting

Perl REGEX

Hi, Can anyone help me to find regular expression for the following in Perl? "The string can only contain lower case letters (a-z) and no more than one of any letter." For example: "table" is accepted, whether "dude" is not. I have coded like this: $str = "table"; if ($str =~ m/\b()\b/) {... (4 Replies)
Discussion started by: evilfreakz
4 Replies

10. Shell Programming and Scripting

q with Perl Regex

For a programming exercise, I am mean to design a Perl script that detects double letters in a text file. I tried the following expressions # Check for any double letter within the alphabet /+/ # Check for any repetition of an alphanumeric character /\w+/ Im aware that the... (8 Replies)
Discussion started by: JamesGoh
8 Replies
Login or Register to Ask a Question