-
-
Save kbbgl/64e7531872911f46b356083e21792988 to your computer and use it in GitHub Desktop.
[match non-greedy] #regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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