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

Add details to the go regexp about.md #2808

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions concepts/regular-expressions/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
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
## Flags
## Flags

Blank line around headings eases reading in plain text.


## 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.
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
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.
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.

Single sentence per line, rather than single line per paragraph.

Choose a reason for hiding this comment

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

你好

Choose a reason for hiding this comment

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

我能请教一个文体吗

Choose a reason for hiding this comment

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

问题

Choose a reason for hiding this comment

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

image

Choose a reason for hiding this comment

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

就是我的go环境为什么运行不了

Choose a reason for hiding this comment

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

然后就是,现在只能靠终端的go run .运行

Copy link
Member

Choose a reason for hiding this comment

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

然后就是,现在只能靠终端的go run .运行

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
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
## Flavor and Performance
## Flavor and Performance

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).
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
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).
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).


## 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].
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
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].
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].


[package-regexp]:https://pkg.go.dev/regexp
[regexp-syntax]:https://pkg.go.dev/regexp/syntax
Expand Down
Loading