![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| regex test in bash | subin_bala | Shell Programming and Scripting | 1 | 04-16-2008 12:27 AM |
| test command looks strange... | jjinno | Shell Programming and Scripting | 2 | 11-02-2007 03:31 PM |
| Help regarding Error message: A test command parameter is not valid | skyineyes | Shell Programming and Scripting | 5 | 06-29-2007 02:38 AM |
| a strange message when executing the sort command | marwan | UNIX for Dummies Questions & Answers | 3 | 04-27-2007 04:32 AM |
| ed strange error message | frenki | Shell Programming and Scripting | 6 | 10-29-2004 03:00 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Strange error message with regex test...
Hi all,
I have a script where i need to check the format of a string. finally, i'm waiting a "process name" and 2 numbers separated by a "," string like : "this_is_a_string.txt,1,10 should be ok" string ok : "apache.exe,1,10" string ok : "mysqld,50,0" string not ok : "ap ache,1,10" string not ok : "ap,ache,1,10" string not ok : " apache,1,10" PS : "" characters are only here to be able to show a string beginning with a space... Here is what i tryed : if [[ $(expr "$PROCESS_STRING" : '^[a-z0-9\-\.\_]*,[0-9]*,[0-9]*$') -ne 0 ]]; then echo " : String OK" else echo " : String KO" fi But i always get an error : expr: WARNING: BRE not portable: « ^[a-z0-9\-\.\_]*,[0-9]*,[0-9]*$ »: use of « ^ » character as first character of a base regular expression isn't portable; canceled. : Format OK The problem seems to be the "^" character at the beginning of my regex, but if i remove it, a string like " apache,1,10" would be ok but it shouldn't in my case... thanks for your help Florent |
| Forum Sponsor | ||
|
|
|
||||
|
Quote:
It works fine with Solaris' /usr/bin/expr and /usr/xpg4/bin/expr |