Regular Expression doesn't match dot "." in a string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regular Expression doesn't match dot "." in a string
# 1  
Old 12-19-2010
Regular Expression doesn't match dot "." in a string

hello,

I am writting a regular expression that intend to match any tunnel or serial interface but it doesn't mtach any serial sub-interface.

For example, statement should match "Tunnel3" or "Serial0/1" but shouldn't match "Serial0\1.1" (doesn't include dot ".")

I tried the following but it doesn't work:
interface (Tunnel.*|Serial.*[^\.].*)
interface (Tunnel.*|Serial[^\.]+)

Please advice.
# 2  
Old 12-19-2010
Instead of Tunnel.* which will match any length and type of characters afterward, you could use
Tunnel[0-9]

It is all about matching, instead of not matching, therefore you have to make "Serial0/1" different than "Serial0\1.1"
In what ways are they different? Serial0/1 would have a space after it, or it would end the line. Serial0\1.1 doesn't.

Then Serial[0-4]/[0-9]([[:space:]]|$) will match Serial{0-4}/{0-9} but not Serial{0-4}/{0-9}.{0-9}
This User Gave Thanks to Aia For This Post:
# 3  
Old 12-20-2010
Hello Aia,

I would like to thank you very much for your interest.

it works fine with me but now, I want RE to match "Serial0" or "Serial0/0" or "Serial0/0/0".

could you please help me to make this RE?

Thanks in advance,
Ahmed
# 4  
Old 12-20-2010
Serial0[/0]*([[:space:]]|$) will match Serial0 or Serial0/0 or Serial0/0/0
This User Gave Thanks to For This Post:
R0H0N
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search file containing ps results for a match "my.cnf" and then for a second match . "ok:" and

I need to find two matches in the output from ps. I am searching with ps -ef |grep mysql for: my.cnf /bin/sh /usr/bin/mysqld_safe --defaults-file=/data/mysql/master/agis_core/etc/my.cnf after this match I want to search back and match the hostname which is x number of lines back, above the... (2 Replies)
Discussion started by: bash_in_my_head
2 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

4. Shell Programming and Scripting

Substituting comma "," for dot "." in a specific column when comma"," is a delimiter

Hi, I'm dealing with an issue and losing a lot of hours figuring out how i would solve this. I have an input file which looks like this: ('BLABLA +200-GRS','Serviço ','TarifaçãoServiço','wap.bla.us.0000000121',2985,0,55,' de conversão em escada','Dia','Domingos') ('BLABLA +200-GRR','Serviço... (6 Replies)
Discussion started by: poliver
6 Replies

5. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

6. Shell Programming and Scripting

grep regex, match exact string which includes "/" anywhere on line.

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)
Discussion started by: jelloir
2 Replies

7. Shell Programming and Scripting

cshell integer expression from "0000" to "1999"

I have 2000 files named like "file-fr0000.log", "file-fr1999.log"... I wanna generate the file names automatically in the following c shell script: set fr = 0 while ($fr <= 1999) grep "ENERGY" file-fr$fr.log > data.dat @ fr = ( $fr + 1 ) end The above will generate file names... (3 Replies)
Discussion started by: rockytodd
3 Replies

8. UNIX for Dummies Questions & Answers

Regular Expression - match 'b' that follows 'a' and is at the end of a string

Hi, I'm struggling with a regex that would match a 'b' that follows an 'a' and is at the end of a string of non-white characters. For example: Line 1: aba abab b abb aab bab baa I can find the right strings but I'm lacking knowledge of how to "discard" the bits that precede bs.... (2 Replies)
Discussion started by: machinogodzilla
2 Replies

9. Linux

Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression

Regular expression to extract "y" from "abc/x.y.z" (2 Replies)
Discussion started by: rag84dec
2 Replies

10. Email Antispam Techniques and Email Filtering

frustrated "No match on" regular expression

attempt to filter "dsl..pacbell.net . . .any pointers? /etc/procmailrc # attempt at egrep regular expression to match # adsl-63-199-245-128.dsl.snd g02.pacbell.net VERBOSE = yes :0 * ^Received:.*dsl+\.+\.pacbell+\.net { LOG="(PacBell DSL) " :0 /zzPacbellDSL } VERBOSE = no... (0 Replies)
Discussion started by: jones
0 Replies
Login or Register to Ask a Question