Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression

Regular expression to extract "y" from "abc/x.y.z"

Regular expressions, as such, only "match", they don't "extract". Some scripting languages have a facility for returning the part of a regular expression which matched, but it then depends on which language you want.

Without more information about what to look for precisely, the simple answer is that the regular expression "y" will match the letter "y", and the matching (extracted) string will always be "y".

If you want the first substring between two periods, that's something like this:

sed -n 's/.*\.\([^.]*\)\..*/\1/p' file

or with Perl:

perl -lne 'if (m/\.([^.]*)\./) { print $1 }' file

or with awk:

awk -F . '{ print $2 }' file

The latter doesn't use regular expressions at all, though.

But really, you need to explain in more detail what the parameters of the problem are.

Hi,

sed 's/.*\.\(.*\)\..*/\1/'

using cut :

cut -d"." -f2

Thanks
Penchal