Added regex description#139
Closed
springtimeday wants to merge 1 commit intoAnthonyCalandra:masterfrom
Closed
Conversation
Owner
|
Thanks for your contribution. I made some comments. Also, could you make the same change to the README.md file? |
AnthonyCalandra
requested changes
Apr 6, 2025
| - [memory model](#memory-model) | ||
| - [std::async](#stdasync) | ||
| - [std::begin/end](#stdbeginend) | ||
| - [regular expressions](#regex) |
Owner
There was a problem hiding this comment.
This should be #regular-expressions
| } | ||
|
|
||
| return 0; | ||
| } |
Owner
There was a problem hiding this comment.
For code sample make sure you enclose them in code blocks (using backticks).
Also for brevity, I don't include headers and a detailed implementation using main since it distracts from the example. Something like this:
// Define a simple regex pattern for an email address.
std::regex email_pattern("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}");
// Input string to check.
std::string email = "example@example.com";
// Check if the input string matches the pattern:
if (std::regex_match(email, email_pattern)) {
// matches
} else {
// no matches
}|
|
||
| The std::regex class is initialized with a regular expression and handles parsing the regular expression. | ||
| std::regex_search() looks for a regex inside a given string, and std::regex_replace() replaces any instances of the regex inside the given string. | ||
| std::regex_iterator and std::regex_token_iterator allow iteration through matches and submatches (respectively) within the string. |
Owner
There was a problem hiding this comment.
Put any class or function names in single backticks please.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added description of regex feature.