Test Regular Expressions on Arrays in Awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Test Regular Expressions on Arrays in Awk
# 1  
Old 03-22-2010
Test Regular Expressions on Arrays in Awk

How would I test for a suffix on an element in an array?

e.g. testing for /$html/ of an element array[x]
# 2  
Old 03-22-2010
Is html a variable defined in your script?
# 3  
Old 03-22-2010
No, sorry, I meant /html$/ i think. That means a string ending in html right?
# 4  
Old 03-22-2010
You are right

Code:
if ( array[x] ~ /html$/ ) { ... }

# 5  
Old 03-23-2010
Thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk or sed or python for regular expressions ?

Linux 6.X environments (RHEL, Oracle Linux ) I could write basic shell scripts in bash. In my spare time, I was planning to learn awk or sed to deal with regular expression tasks I have to deal with. But, I gather that python is gaining popularity these days and I came to know that python has a... (5 Replies)
Discussion started by: John K
5 Replies

2. Shell Programming and Scripting

Assistance required with awk and regular expressions

Hello there, I am trying to get my head around the section below of a script we use that incorporates AWK and Regular Expressions. { match($0,"The broker*");print $1,$2,$3 ":", substr($0, RSTART,RLENGTH)} I have a basic understanding of how match works, what I am struggling with is the... (2 Replies)
Discussion started by: jimbojames
2 Replies

3. Shell Programming and Scripting

Handling regular expressions in awk

Script is: accept filename as argument(also handle CTRL+C).to check whether th file exist in the current directory,it it then using awk find the employees who are either born in 1990 or drawing a salary greater than 25000. In my database file 1st field is of id ,2nd field is name,5th field is of... (5 Replies)
Discussion started by: Priyanka Bhati
5 Replies

4. Shell Programming and Scripting

Regular Expressions

#!/usr/bin/perl $word = "one last challenge"; if ( $word =~ /^(\w+).*\s(\w+)$/ ) { print "$1"; print "\n"; print "$2"; } The output shows that "$1" is with result one and "$2" is with result challenge. I am confused about how this pattern match expression works step by step. I... (8 Replies)
Discussion started by: DavidHe
8 Replies

5. Shell Programming and Scripting

Awk regular expressions

Hi Experts, Can you please help me out for the below scenario, I have a variable length file with the fixed number of columns, in which the fields are delimited by pipe symbol (|). From that file I have to extract the lines which has the following scenario, The field1 in a... (1 Reply)
Discussion started by: chella
1 Replies

6. Shell Programming and Scripting

how to test the regular expressions

Hi, lam taking the IP address as input from the user. I want to test whether the user has entered the IP address in the right format or not. Can any one suggest me the syntax to test the user given IP address ASAP. Its a bit urgent. Regards, :) (2 Replies)
Discussion started by: vnPrasanna
2 Replies

7. Shell Programming and Scripting

Regular Expressions

How can i create a regular expression which can detect a new line charcter followed by a special character say * and replace these both by a string of zero length? Eg: Input File san.txt hello hi ... (6 Replies)
Discussion started by: sandeep_hi
6 Replies

8. Shell Programming and Scripting

can arrays be used in regular expressions?

anyone know if there is a way to use an array in a regular expression. suppose i want to find out if $sometext contains one of an array's elements. Obviously the code below doesn't work, but is there something similar that does work? @array = qw/thing1 thing2 thing3/; if ($sometext =~... (3 Replies)
Discussion started by: quantumechanix
3 Replies

9. Programming

regular expressions in c++

How do I use the regular expressions in c++? (2 Replies)
Discussion started by: szzz
2 Replies
Login or Register to Ask a Question