Skip to content

Instantly share code, notes, and snippets.

@kbbgl
Created May 7, 2020 16:57
Show Gist options
  • Save kbbgl/64e7531872911f46b356083e21792988 to your computer and use it in GitHub Desktop.
Save kbbgl/64e7531872911f46b356083e21792988 to your computer and use it in GitHub Desktop.
[match non-greedy] #regex
# using the ? means that we're not matching greedily
echo "<p>Paragraph 1</p><p>Paragraph 2</p><p>Paragraph 3</p>" | grep -P "<p>.*?</p>" # will match <p>Paragraph 1</p>, <p>Paragraph 2</p>, <p>Paragraph 3</p>
# we can use the ? to match an optional character
echo "http:\\website.com,https:\\website2.com" | grep -P "https?.*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment