What is the regular expression for REVERSE of five consecutive nubmers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What is the regular expression for REVERSE of five consecutive nubmers
# 1  
Old 09-24-2009
What is the regular expression for REVERSE of five consecutive nubmers

Hi , we all know that the regex for five consecutive number is [0-9][0-9][0-9][0-9][0-9]

But what is the regex for "anything but five consecutive numbers"

I want to use an awk script to replace anything but five consecutive numbers with blank, so that 3423ljljaj43222jkjlj2fasd becomes 43222
# 2  
Old 09-24-2009
you can use grep for that.

Code:
grep -Ev '[0-9]{5}' file

or

Code:
echo $var | grep -Ev '[0-9]{5}'


for awk, you can negate the condition.

Code:
$0 !~ /regex/

# 3  
Old 09-24-2009
try this

Code:
awk -F[a-z]+ '{print $2}' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular expression

Hello Gurus, I am looking for regular expressions for awk to filter on second column 2nd and 3rd digit Using in code something like: awk '{if ( $2 == "0::" ) print} source file: 0 0:0:0 FC 15 normal 559104 51200 0:3:1* 1:3:1 600 1 0:0:1 FC 15 normal ... (2 Replies)
Discussion started by: vishalgoyal
2 Replies

2. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

3. Shell Programming and Scripting

Help with regular expression

I have file with following data, http://www.some.com/web11.html http://www.some.com/web/112.html http://www.some.com/web/21.html http://www.some.com/342.html http://www.some.com/plk.html http://www.some.com/abh.html http://www.some.com/yte.html http://www.some.com/tyr/098.html... (4 Replies)
Discussion started by: sol_nov
4 Replies

4. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

5. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

6. Shell Programming and Scripting

Regular Expression

Hi All, This regular expression is in awk. What does this regular expression evaluate to(character by character). ($0 ~ /^ .+*(|-).+*\*+.?*\*/) (2 Replies)
Discussion started by: mradsus
2 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Regular expression

Hello, I have a string of the form " &x.y.z" I would like to grep all the lines when "in" can be found in either x or y. How to write the corresponding regular expression ? I have tried the following but it does not work: grep -i " *&.*(in)*.*.*(in)*.*" Any ideas ? Thank you Max (1 Reply)
Discussion started by: maxvirrozeito
1 Replies

9. Programming

help in regular expression

Hi all, I'm working with flex (version 2.5.4a) on GNU/linux. I need to frame a regular expression which would match cases where word "file" does not occur. Negated character class wont work for me because they enforce "or" clause between different chars (so something like wont work). I would like... (5 Replies)
Discussion started by: Rakesh Ranjan
5 Replies

10. Shell Programming and Scripting

Regular Expression + Aritmetical Expression

Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant. THX! (2 Replies)
Discussion started by: Z0mby
2 Replies
Login or Register to Ask a Question