Get Comparison operators from with RexExp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get Comparison operators from with RexExp
# 1  
Old 07-19-2006
Get Comparison operators from with RexExp

Hello all

im trying to get the Comparison operators from string with out much success
I have :
$myvar = "if (hhhh <= blah.count )" ;

when I do :
if ($myvar =~ m/.*([<=|=|<|>|>=]).*/){
.......
}
I keep getting the "=" and not "<="
why ?
# 2  
Old 07-19-2006
Try :
Code:
if ($myvar =~ m/.*(<=|=|<|>|>=).*/){

Jean-Pierre.
# 3  
Old 07-19-2006
Tnx for the fast reply but no... it still dont catch if i have :
$myvar = "if (hhhh <= blah.count )" ;

it finds me in the $1 "=" and not "<="
?
# 4  
Old 07-19-2006
in the same metter

how can i recognize match of word duplication in string
for example if i have :
"blah.foo(blah.ggg)"
how can i know with regexp that i have duplication of "blah"?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

operators in if loop

Hi all, I have a variable which is having the value like below, $ echo ${p} 8 15 22 30 $ My requirement is that the variable should return true when it contains only one number like below, $ echo ${p} 15 $ Otherwise, it should return false if it contains more than one number. I... (4 Replies)
Discussion started by: raghu.iv85
4 Replies

2. Homework & Coursework Questions

Operators

I really don't know the meaning of these operators. Could someone explain the meanings? <, <=, ==, !=, >=, >, ||, &&, ! ~ , !~ Thanks! (1 Reply)
Discussion started by: Erjen
1 Replies

3. Shell Programming and Scripting

Operators

I really don't know the meaning of these operators. Could someone explain the meanings so I can make my test for today? <, <=, ==, !=, >=, >, ||, &&, ! ~ , !~ Thanks! (1 Reply)
Discussion started by: Erjen
1 Replies

4. Shell Programming and Scripting

And and OR Operators with If Statement.

Hi All, I have 2 variables. Result1 and Result2. I want to put a condition that if Both are True then echo "All True" Else Show Error. Right now i am doing this and getting error. if ; then echo "All True" else echo "Failed" fi; Error. line 8: ' Solution: Looking for (2 Replies)
Discussion started by: mkashif
2 Replies

5. UNIX for Dummies Questions & Answers

Comparison operators: shortcut name

There are a number of comparison operators used in scripting and programming languages, such as the following: =, ==, ===, !=, =~, <, >, <=, >=, etc Is there a shortcut name for them, such as one has for as being any capital letter? If not, it would mean that I would have to list them all for a... (2 Replies)
Discussion started by: figaro
2 Replies

6. Shell Programming and Scripting

string comparison operators, what are they??

hi guys im a newbie to shell scripting and would appreciate any help possible. my questions will be very straight forward and relatively trivial to most of you. as the thread title is asking, what are the operators?? i know there's the != and =, but for bourne and c shell, what are the... (12 Replies)
Discussion started by: ballazrus
12 Replies

7. UNIX for Dummies Questions & Answers

Operators

I am trying to understand Does the following: {tmp+=$10} Mean take $10 and add them all up and call it tmp thanks! (2 Replies)
Discussion started by: llsmr777
2 Replies

8. UNIX for Dummies Questions & Answers

Arithmetic Operators

Hello, I have a list of 'inputs' and i want to convert those on the second list named 'Desired Outputs', but i don't know how to do it? Inputs Desired Outputs 1 2 94 4 276 8 369 10 464 12 ... (0 Replies)
Discussion started by: filda
0 Replies

9. UNIX for Advanced & Expert Users

If with set operators

Hi guys, I'm trying to run more than one "if" condition at once. What I want is something like if ] or ] or ]; then ... I can't remember the syntax for using this or/and set operators. Can someone please assist/ jog my memory? thanks Khoom (2 Replies)
Discussion started by: Khoomfire
2 Replies
Login or Register to Ask a Question