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.

Wrong input, deleted........

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.

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

How about this:

[AB].-...-......-... ../.

or if any string between AB1 and (space) you could also give this a try:

[AB].-.* ../.

OR

[A].* ../.

Take whatever suits your requirements.

Regards,
Tayyab

sed -e "s_..[a-zA-Z0-9]-[a-zA-Z0-9]\{3\}-[a-zA-Z0-9]\{6\}-[a-zA-Z0-9]\{3\}_&_"

Its grep equivalent

grep -E "..[[:alnum:]]-[[:alnum:]]{3}-[[:alnum:]]{6}-[[:alnum:]]{3}"
grep -E "..\w-\w{3}-\w{6}-\w{3}"

\w is a synonym for [[:alnum:]]