J'ai vu beaucoup de réponses, mais aucune ne semble m'aider avec ma situation. Je dois extraire les commentaires de ce texte:Comment utiliser | opérateur dans preg_match pour rechercher entre les chaînes?
Comments: These are the comments and they end at this full stop. Remember, you can only use the personal information...
OU ce texte:
Comments: These are the comments and they end at this full stop. You can only use the personal information...
Un exemple de travail est ici: https://regex101.com/r/apIT0O/1
Mais je ne peux pas sembler obtenir ceci en PHP. Je peux obtenir un pour travailler avec:
$pattern = "/(?<=Comments:)(.*?)(?= Remember, you can)/s";
Mais quel est le problème avec cela?
$pattern = "/(?<=Comments:)(.*?)(?= Remember, you can)|(?<=Comments:)(.*?)(?= You can)/s";
Merci beaucoup!
En fait, ils [correspondent] (https://eval.in/697037) au contexte que vous souhaitez capturer. Mais je recommanderais une approche différente avec votre expression. – hwnd