WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@UdeshyaDhungana
Copy link
Contributor

@UdeshyaDhungana UdeshyaDhungana commented Nov 12, 2025

Note

Adds a new “Multiple Matches” extension (with -o flag) and three stages for printing single/multiple matches across single and multiple lines, updating course-definition and adding stage description docs.

  • Extensions:
    • multiple-matches: New extension describing -o (only-matching) behavior.
  • Stages (added to course-definition.yml):
    • cj0 — Print single match (medium)
    • ss2 — Print multiple matches in one line (medium)
    • bo4 — Process multiple input lines for matches (medium)
  • Stage Descriptions:
    • stage_descriptions/multiple-matches-01-cj0.md: Explains -o, single match behavior, tests, exit codes.
    • stage_descriptions/multiple-matches-02-ss2.md: Multiple matches per line, examples, tests, exit codes.
    • stage_descriptions/multiple-matches-03-bo4.md: Multiple lines support, examples, tests, exit codes.

Written by Cursor Bugbot for commit 7e146bc. This will update automatically on new commits. Configure here.

@UdeshyaDhungana UdeshyaDhungana changed the title Add stage instructions for multiple matches Grep/Multiple Matches Nov 12, 2025
@github-actions
Copy link

github-actions bot commented Nov 12, 2025

LLM Doc Lint

70 tests   65 ✅  0s ⏱️
 5 suites   0 💤
 1 files     5 ❌

For more details on these failures, see this check.

Results for commit de7f8c3.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 12, 2025

LLM Doc Lint

70 tests   69 ✅  0s ⏱️
 5 suites   0 💤
 1 files     1 ❌

For more details on these failures, see this check.

Results for commit 4e3e44c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 12, 2025

LLM Doc Lint

70 tests   70 ✅  0s ⏱️
 5 suites   0 💤
 1 files     0 ❌

Results for commit ba3dadc.

♻️ This comment has been updated with latest results.

Copy link
Member

@rohitpaulk rohitpaulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be far more minimal - let's remove the uncommon options and focus only on whatever's needed for multiple matches.

Also wonder if we should split this into two: "Printing matches" and "Multiple matches"?

The first can test printing lines that are matched (can be two stages: Single-line matches, Multi-line matches).

The second can test multiple matches specifically by introducing the -o flag.


### The `-c` option

The `-c` option, also known as the count option, is used to count the number of lines which match the specified pattern.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@UdeshyaDhungana I don't think we need to add this option - it can be indirectly tested by just getting users to print lines.

We aren't looking to get full coverage of CLI options, just full coverage of common operations. I think the common usage here is just cat XYZ | grep "pattern" | wc -l, and we'll already have this covered if we test printing lines.

The next stage could be the first stage for this extension! Don't think there's any significant difference in implementation difficulty, and this adds an additional concept + more implementation work (the -c flag).

```

If none of the lines match the specified pattern, your program must:
- Exit with the code 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also test that nothing is printed to stdout

Example usage:

```bash
$ echo -ne "dogs\ncat\ndog" | grep -n -E "dogs?"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ignore this stage - isn't a commonly used flag. And it also doesn't really help with multiple matches, since even if a line had multiple matches the line would be printed only once.

@@ -0,0 +1,35 @@
In this stage, you'll add support for stopping the pattern search after a specified number of lines have been matched.

### The `-m` option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's skip this too! Not a common option


### The `-o` flag

The `-o` flag, also known as the `only-matching` flag, is used to print only the matching texts in a separate line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably worth keeping in, since it tests multiple matches directly (one printed per line).

@github-actions
Copy link

github-actions bot commented Nov 14, 2025

LLM Doc Lint

42 tests   39 ✅  0s ⏱️
 3 suites   0 💤
 1 files     3 ❌

For more details on these failures, see this check.

Results for commit a210401.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 14, 2025

LLM Doc Lint

42 tests   41 ✅  0s ⏱️
 3 suites   0 💤
 1 files     1 ❌

For more details on these failures, see this check.

Results for commit 6045ea2.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 14, 2025

LLM Doc Lint

42 tests   42 ✅  0s ⏱️
 3 suites   0 💤
 1 files     0 ❌

Results for commit 93a58f3.

♻️ This comment has been updated with latest results.

# Multiple matches
- slug: "cj0"
primary_extension_slug: "multiple-matches"
name: "Print a single matching text"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: "Print a single matching text"
name: "Print single match"

- slug: "ss2"
primary_extension_slug: "multiple-matches"
name: "Print multiple matching texts"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: "Print multiple matching texts"
name: "Print multiple matches"

@github-actions
Copy link

github-actions bot commented Nov 17, 2025

LLM Doc Lint

42 tests   42 ✅  0s ⏱️
 3 suites   0 💤
 1 files     0 ❌

Results for commit 20021dd.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 24, 2025

LLM Doc Lint

45 tests   44 ✅  0s ⏱️
 3 suites   0 💤
 1 files     1 ❌

For more details on these failures, see this check.

Results for commit f447509.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 24, 2025

LLM Doc Lint

45 tests   45 ✅  0s ⏱️
 3 suites   0 💤
 1 files     0 ❌

Results for commit 7e146bc.

♻️ This comment has been updated with latest results.

@UdeshyaDhungana UdeshyaDhungana merged commit 66a82bf into main Nov 24, 2025
24 checks passed
@UdeshyaDhungana UdeshyaDhungana deleted the multiple-matches branch November 24, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants