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

v0.3.0-beta版本首层目录正则表达式不准确 #22

Open
Robin329 opened this issue May 26, 2023 · 2 comments
Open

v0.3.0-beta版本首层目录正则表达式不准确 #22

Robin329 opened this issue May 26, 2023 · 2 comments

Comments

@Robin329
Copy link

目录文本:

Contents
1 INTRODUCTION AND SCOPE ................................................................................................................ 4
1.1 SUPPORTED FEATURE LIST ..................................................................................................................................5
1.2 STANDARDS COMPLIANCE...................................................................................................................................6

首层:^[1-9]\d*
二层:^[1-9]\d*.\d*
三层:^[1-9]\d*.[1-9]\d*.[1-9]\d*

@chroming
Copy link
Owner

是首层被识别成二层了么? 首层文本能同时匹配当前的首层和二层正则,所以被当成二层了。优化一下正则最后加个空格就能更精确匹配了

@ArtisticZhao
Copy link
Contributor

@Robin329 正则表达式需要更加精确, 底层逻辑是从高层级的匹配优先级更高, 如果满足的二级的正则表达式, 则目录被归为二级.

英文目录匹配可以参考这组正则:

^\d+\.\s\?
^\d+\.\d+\w?\s?
^\d+\.\d+\.\d+\w?\s?
^\d+\.\d+\.\d+\.\d+\w?\s?
^\d+\.\d+\.\d+\.\d+\.\d+\w?\s?
^\d+\.\d+\.\d+\.\d+\.\d+\.\d+\w?\s?

这组正则支持 正常的英文目录, 以及类似 1.1a 这种额外的标记; 同时支持目录标记与标题贴贴的情况 如 1.1.1balabal

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

No branches or pull requests

3 participants