Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 带参数的 RegexStr() #2499

Merged
merged 1 commit into from
Jan 11, 2024
Merged

Feature: 带参数的 RegexStr() #2499

merged 1 commit into from
Jan 11, 2024

Conversation

ProgramRipper
Copy link
Member

Match.group() 无参数时返回整个正则表达式匹配的字符串, 也可以通过传入参数获得特定的捕获组.
RegexStr() 现在只支持无参数调用, 不支持传入参数.

此 pull request 实现了向 RegexStr() 传入参数以获得特定捕获组的功能.
例:

matcher = on_regex(r"\[cq:(?P<type>.*?),(?P<arg>.*?)\]")


@matcher.handle()
async def _(type_: str = RegexStr(1), arg: str = RegexStr("arg")):
    ...

Copy link

codecov bot commented Dec 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b939237) 92.07% compared to head (ae678a4) 92.07%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2499   +/-   ##
=======================================
  Coverage   92.07%   92.07%           
=======================================
  Files          47       47           
  Lines        3594     3596    +2     
=======================================
+ Hits         3309     3311    +2     
  Misses        285      285           
Flag Coverage Δ
unittests 92.07% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

🚀 Deployed on https://deploy-preview-2499--nonebot2.netlify.app

@github-actions github-actions bot temporarily deployed to pull request December 25, 2023 18:06 Inactive
@yanyongyu yanyongyu added the enhancement New feature or request label Dec 26, 2023
@yanyongyu yanyongyu changed the title Feat: 带参数的 RegexStr() Feature: 带参数的 RegexStr() Jan 11, 2024
@yanyongyu yanyongyu merged commit 5a6f4b9 into master Jan 11, 2024
27 checks passed
@yanyongyu yanyongyu deleted the feat/regex-str branch January 11, 2024 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants