Introduction aux expressions régulières

Texte de Travail : ZOLA

  • Chercher toutes les lignes commençant par «a» ou «A».

Commande: egrep -i ^[aA]  zola*
  • Chercher toutes les lignes finissant par «rs».

Commande: egrep "rs"$ zola*
  • Chercher toutes les lignes contenant au moins un chiffre.

Commande: egrep [0-9]+ zola*

  • Chercher toutes les lignes commençant par une majuscule.

Commande: egrep ^[A-Z] zola*
  • Chercher toutes les lignes commençant par «B», «E» ou «Q».

Commande: egrep ^[BEQ] zola*
  • Chercher toutes les lignes finissant par un point d'exclamation.

Commande: egrep \!$ zola*
  • Chercher toutes les lignes ne finissant pas par un signe de ponctuation (point, virgule, point-virgule, deux-points, point d'interrogation, point d'exclamation).

Commande: egrep [^\;\.\?\!\:\,]$ zola*
  • Chercher tous les mots contenant un «r» précédé de n'importe quelle lettre majuscule ou minuscule.

Commande: egrep "\b[a-zA-Z]+r\w+"  zola*
  • Chercher tous les mots dont la seconde lettre est un «r».

   Commande: egrep "\b[a-zA-Z]r\w+" zola*