![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum 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 |
| Regular Expression Problem | chris1234 | UNIX for Dummies Questions & Answers | 12 | 04-02-2008 04:44 AM |
| awk and regular expression | maskot | Shell Programming and Scripting | 4 | 05-22-2007 04:22 AM |
| Regular Expression Problem | netmaster | UNIX for Dummies Questions & Answers | 1 | 12-07-2005 06:34 PM |
| Complex Pipeline/Redirection/Regular Expression problem | netmaster | UNIX for Dummies Questions & Answers | 1 | 11-28-2005 09:55 PM |
| Regular Expression + Aritmetical Expression | Z0mby | Shell Programming and Scripting | 2 | 05-21-2002 07:59 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Regular Expression problem
Hi guys
I've been trying to write a regular expression. If I'm tryin to validate a sequence of characters as follows... AB1-232-623482-743 43/3 where a) any character after the "AB" can be any alphanumeric character b) the " 43/3" part is optional is there a quick neat way for me to do this? i know i could do something like regexp=[A][b][A-Za-z0-9]-[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9] etc etc but this looks like a very untidy way to it.. Any help would br greatly appreciated. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Wrong input, deleted........
Last edited by tayyabq8; 06-21-2006 at 07:09 AM. |
|
#3
|
|||
|
|||
|
no. that won't work because the optional section needs to be validated to contain only a space followed by 2 alphanumeric characters, a forawrd slash and a further alphanumeric character.
All characters in the string must be validated therefore it is not possible to use * thanks for trying though. |
|
#4
|
||||
|
||||
|
Sorry for misunderstanding your requirements, I thought you were saying that AB1 and then any string, I'll work on your requirement and will come up with something neat.
Regards, Tayyab |
|
#5
|
||||
|
||||
|
How about this:
Code:
[AB].-...-......-... ../. Code:
[AB].-.* ../. Code:
[A][b].* ../. Regards, Tayyab Last edited by tayyabq8; 06-21-2006 at 07:06 AM. |
|
#6
|
||||
|
||||
|
Code:
sed -e "s_..[a-zA-Z0-9]-[a-zA-Z0-9]\{3\}-[a-zA-Z0-9]\{6\}-[a-zA-Z0-9]\{3\}_&_"
Code:
grep -E "..[[:alnum:]]-[[:alnum:]]{3}-[[:alnum:]]{6}-[[:alnum:]]{3}"
grep -E "..\w-\w{3}-\w{6}-\w{3}"
|
||||
| Google The UNIX and Linux Forums |