-
-
Notifications
You must be signed in to change notification settings - Fork 657
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
Add details to the go regexp about.md #2808
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,7 +4,7 @@ Package [regexp][package-regexp] offers support for regular expressions in Go. | |||||||||||
|
||||||||||||
## Syntax | ||||||||||||
|
||||||||||||
The [syntax][regexp-syntax] of the regular expressions accepted is the same general syntax used by Perl, Python, and other languages. | ||||||||||||
The [syntax][regexp-syntax] of the regular expressions accepted is the same general syntax used by Perl, Python, and other languages. | ||||||||||||
|
||||||||||||
Both the search patterns and the input texts are interpreted as UTF-8. | ||||||||||||
|
||||||||||||
|
@@ -137,17 +137,18 @@ sl = re.Split("12abc34(ef)", 2) // => []string{"12","(ef)"} | |||||||||||
sl = re.Split(" abc!", -1) // => []string{" ","!"} | ||||||||||||
sl = re.Split("123 456", -1) // => []string{"123 456"} | ||||||||||||
``` | ||||||||||||
## Flags | ||||||||||||
|
||||||||||||
## Performance | ||||||||||||
Flags change the rules that regular expression's use to search for patterns. The main flags are i for case insensitivity, m for multiline matching, s for . to match \n, and U for ungreedy or lazy matching (x* and x*?, x+ and x+? have swapped meanings). In order to set a flag in go, we include the flag preceding the regular expression pattern in the format (?x) where x is the flag. | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Single sentence per line, rather than single line per paragraph. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 你好 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我能请教一个文体吗 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 问题 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 就是我的go环境为什么运行不了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 然后就是,现在只能靠终端的go run .运行 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You may want to ask for help in our Discord server or on the forms. This is not really the place to ask about user choice configurations, such as editors or IDE's. But when asking please do give information that describes your environment and your tools, such as your editor. Also, if possible, please do use English, it will help get eyes on this problem as wide as possible, so that you can get the assistance you are asking for. எங்கள் டிஸ்கார்ட் சர்வரில் அல்லது படிவங்களில் நீங்கள் உதவி கேட்கலாம். எடிட்டர்கள் அல்லது ஐடிஇகள் போன்ற பயனர் தேர்வு உள்ளமைவுகளைப் பற்றி கேட்க இது உண்மையில் இடம் இல்லை. ஆனால் கேட்கும் போது, உங்கள் சூழல் மற்றும் உங்கள் எடிட்டர் போன்ற உங்கள் கருவிகளை விவரிக்கும் தகவலை கொடுங்கள். மேலும், முடிந்தால், தயவு செய்து ஆங்கிலத்தைப் பயன்படுத்தவும், இந்த பிரச்சனையை முடிந்தவரை பரந்த அளவில் பார்க்க இது உதவும், இதன் மூலம் நீங்கள் கேட்கும் உதவியைப் பெற முடியும். |
||||||||||||
|
||||||||||||
The regexp implementation provided by this package is guaranteed to run in | ||||||||||||
[time linear in the size of the input][re2-performance]. | ||||||||||||
## Flavor and Performance | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Inserts blank line for "blank line around headings. |
||||||||||||
|
||||||||||||
The specific flavor, or regular expression engine, of Go is google's RE2. This flavor is guaranteed to run in [time linear in the size of the input][re2-performance] and has a fixed recursive stack, but does not allow for back tracking operations (i.e. matching patterns backwards from right to left). | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
## Caveat | ||||||||||||
|
||||||||||||
Package `regexp` implements [RE2 regular expressions][re2-syntax] (except for `\C`). | ||||||||||||
The syntax is largely compatible with PCRE ("Perl Compatible Regular Expression"), but there are some differences. | ||||||||||||
Please see the "Caveat section" in [this article][reg-exp-wild] for details. | ||||||||||||
The syntax is largely compatible with PCRE ("Perl Compatible Regular Expression"), but there are some differences and features that are not included in the RE2 library. For example, RE2 does not support lookahead assertions, lookbehind assertions, or backreferences. Additionally, RE2 is less efficient at parantheses capturing operations. Further and more specific syntactical differences can be found in the "Caveat section" in [this article][reg-exp-wild]. | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
[package-regexp]:https://pkg.go.dev/regexp | ||||||||||||
[regexp-syntax]:https://pkg.go.dev/regexp/syntax | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line around headings eases reading in plain text.