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

Conversation

alecswift
Copy link

Hi,

I opened a topic on the forum about this old issue. I didn't receive a response on the forum from the go team. I figured I'd attempt to open a pull request as well, since I would love to contribute. Here's the forum post. Thank you!

Copy link
Contributor

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this May 30, 2024
@andrerfcsantos
Copy link
Member

Re-opening this as I believe this is relevant. The PR adds explanations about flags, which is relevant for the context of this exercise.

In particular, in this exercise, the use of the case-insensitive flag i can be helpful.

My suggestion here is to add a bit more on how to use those flags, and maybe show an example of a match with and without a particular flag. I don't think it's necessary to show examples for all flags, maybe just showing an example of the i flag is enough.

@alecswift Do you still want to work on this? Totally fine if you don't, just let us know and we can finish it for you - you'll still get credited.

Copy link
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

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

Some styling suggestions, the single sentence per line is documented in the contributing documentation.


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


எங்கள் டிஸ்கார்ட் சர்வரில் அல்லது படிவங்களில் நீங்கள் உதவி கேட்கலாம். எடிட்டர்கள் அல்லது ஐடிஇகள் போன்ற பயனர் தேர்வு உள்ளமைவுகளைப் பற்றி கேட்க இது உண்மையில் இடம் இல்லை.

ஆனால் கேட்கும் போது, ​​உங்கள் சூழல் மற்றும் உங்கள் எடிட்டர் போன்ற உங்கள் கருவிகளை விவரிக்கும் தகவலை கொடுங்கள்.

மேலும், முடிந்தால், தயவு செய்து ஆங்கிலத்தைப் பயன்படுத்தவும், இந்த பிரச்சனையை முடிந்தவரை பரந்த அளவில் பார்க்க இது உதவும், இதன் மூலம் நீங்கள் கேட்கும் உதவியைப் பெற முடியும்.

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

[time linear in the size of the input][re2-performance].
## Flavor and Performance

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


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.


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

@Gingesmallfish
Copy link

你好

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.

4 participants