samedi 27 juin 2015

is there any named regular expression capture for grep?

i'd like to know if its possible to get named regular expression with grep -P(linux bash) from a non formatted string? well.. from any string

For example: John Smith www.website.com john@website.com jan-01-2001 to capture as

$name
$website
$email
$date

but it seems I cant pass any variables from output?

echo "www.website.com" | grep -Po '^(www\.)?(?<domain>.+)$' | echo $domain

has no output

Aucun commentaire:

Enregistrer un commentaire