Skip to content

Commit dfebbe2

Browse files
authored
[docs concepts/regular-expressions] replace "routine" with "method" (#2972)
1 parent 39114e0 commit dfebbe2

2 files changed

Lines changed: 36 additions & 36 deletions

File tree

concepts/regular-expressions/introduction.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
Package [regexp][package-regexp] offers support for regular expressions in Go.
44

5-
## Syntax
5+
## Syntax
66

7-
The [syntax][regexp-syntax] of the regular expressions accepted is the same general syntax used by Perl, Python, and other languages.
7+
The [syntax][regexp-syntax] of the regular expressions accepted is the same general syntax used by Perl, Python, and other languages.
88

9-
Both the search patterns and the input texts are interpreted as UTF-8.
9+
Both the search patterns and the input texts are interpreted as UTF-8.
1010

1111
When using backticks (\`) to make strings, backslashes (`\`) don't have any special meaning and don't mark the beginning of special characters like tabs `\t` or newlines `\n`:
1212

@@ -39,29 +39,29 @@ re, err = regexp.Compile(`a|b)+`)
3939
fmt.Println(re, err) // => <nil> error parsing regexp: unexpected ): `a|b)+`
4040
```
4141

42-
Function `MustCompile` is a convenient alternative to `Compile`:
42+
Function `MustCompile` is a convenient alternative to `Compile`:
4343

44-
```go
44+
```go
4545
re = regexp.MustCompile(`[a-z]+\d*`)
4646
```
4747

48-
Using this function, there is no need to handle an error.
48+
Using this function, there is no need to handle an error.
4949

5050
~~~~exercism/caution
5151
`MustCompile` should only be used when we know for sure the pattern does compile, as otherwise the program will panic.
5252
~~~~
53-
53+
5454
## Regular expression methods
55-
55+
5656
There are 16 methods of `Regexp` that match a regular expression and identify the matched text.
5757
Their names are matched by this regular expression:
5858

5959
```text
6060
Find(All)?(String)?(Submatch)?(Index)?
6161
```
6262

63-
* If `All` is present, the routine matches successive non-overlapping matches of the entire expression.
64-
* If `String` is present, the argument is a string; otherwise it is a slice of bytes; return values are adjusted as appropriate.
63+
* If `All` is present, the method matches successive non-overlapping matches of the entire expression.
64+
* If `String` is present, the argument is a string; otherwise it is a slice of bytes; return values are adjusted as appropriate.
6565
* If `Submatch` is present, the return value is a slice identifying the successive submatches of the expression.
6666
* If `Index` is present, matches and submatches are identified by byte index pairs within the input string.
6767

@@ -73,8 +73,8 @@ There are also methods for:
7373
All-in-all, the `regexp` package defines more than 40 functions and methods.
7474
We will demonstrate the use of a few methods below.
7575
Please see the [API documentation][package-regexp] for details of these and other functions.
76-
77-
### `MatchString` Examples
76+
77+
### `MatchString` Examples
7878

7979
Method `MatchString` reports whether a string contains any match of a regular expression.
8080

@@ -83,10 +83,10 @@ re = regexp.MustCompile(`[a-z]+\d*`)
8383
b = re.MatchString("[a12]") // => true
8484
b = re.MatchString("12abc34(ef)") // => true
8585
b = re.MatchString(" abc!") // => true
86-
b = re.MatchString("123 456") // => false
86+
b = re.MatchString("123 456") // => false
8787
```
8888

89-
### `FindString` Examples
89+
### `FindString` Examples
9090

9191
Method `FindString` returns a string holding the text of the leftmost match of the regular expression.
9292

@@ -104,7 +104,7 @@ Method `FindStringSubmatch` returns a slice of strings holding the text of the l
104104
This can be used to identify the strings matching capturing groups.
105105
A return value of `nil` indicates no match.
106106

107-
```go
107+
```go
108108
re = regexp.MustCompile(`[a-z]+(\d*)`)
109109
sl = re.FindStringSubmatch("[a12]") // => []string{"a12","12"}
110110
sl = re.FindStringSubmatch("12abc34(ef)") // => []string{"abc34","34"}
@@ -123,9 +123,9 @@ s = re.ReplaceAllString("12abc34(ef)", "X") // => "12X(X)"
123123
s = re.ReplaceAllString(" abc!", "X") // => " X!"
124124
s = re.ReplaceAllString("123 456", "X") // => "123 456"
125125
```
126-
126+
127127
### `Split` Examples
128-
128+
129129
Method `re.Split(s,n)` slices a text `s` into substrings separated by the expression and returns a slice of the substrings between those expression matches.
130130
The count `n` determines the maximal number of substrings to return.
131131
If `n<0`, the method returns all substrings.
@@ -137,6 +137,6 @@ sl = re.Split("12abc34(ef)", 2) // => []string{"12","(ef)"}
137137
sl = re.Split(" abc!", -1) // => []string{" ","!"}
138138
sl = re.Split("123 456", -1) // => []string{"123 456"}
139139
```
140-
140+
141141
[package-regexp]: https://pkg.go.dev/regexp
142142
[regexp-syntax]: https://pkg.go.dev/regexp/syntax

exercises/concept/parsing-log-files/.docs/introduction.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
Package [regexp][package-regexp] offers support for regular expressions in Go.
44

5-
## Syntax
5+
## Syntax
66

7-
The [syntax][regexp-syntax] of the regular expressions accepted is the same general syntax used by Perl, Python, and other languages.
7+
The [syntax][regexp-syntax] of the regular expressions accepted is the same general syntax used by Perl, Python, and other languages.
88

9-
Both the search patterns and the input texts are interpreted as UTF-8.
9+
Both the search patterns and the input texts are interpreted as UTF-8.
1010

1111
When using backticks (\`) to make strings, backslashes (`\`) don't have any special meaning and don't mark the beginning of special characters like tabs `\t` or newlines `\n`:
1212

@@ -39,29 +39,29 @@ re, err = regexp.Compile(`a|b)+`)
3939
fmt.Println(re, err) // => <nil> error parsing regexp: unexpected ): `a|b)+`
4040
```
4141

42-
Function `MustCompile` is a convenient alternative to `Compile`:
42+
Function `MustCompile` is a convenient alternative to `Compile`:
4343

44-
```go
44+
```go
4545
re = regexp.MustCompile(`[a-z]+\d*`)
4646
```
4747

48-
Using this function, there is no need to handle an error.
48+
Using this function, there is no need to handle an error.
4949

5050
~~~~exercism/caution
5151
`MustCompile` should only be used when we know for sure the pattern does compile, as otherwise the program will panic.
5252
~~~~
53-
53+
5454
## Regular expression methods
55-
55+
5656
There are 16 methods of `Regexp` that match a regular expression and identify the matched text.
5757
Their names are matched by this regular expression:
5858

5959
```text
6060
Find(All)?(String)?(Submatch)?(Index)?
6161
```
6262

63-
* If `All` is present, the routine matches successive non-overlapping matches of the entire expression.
64-
* If `String` is present, the argument is a string; otherwise it is a slice of bytes; return values are adjusted as appropriate.
63+
* If `All` is present, the method matches successive non-overlapping matches of the entire expression.
64+
* If `String` is present, the argument is a string; otherwise it is a slice of bytes; return values are adjusted as appropriate.
6565
* If `Submatch` is present, the return value is a slice identifying the successive submatches of the expression.
6666
* If `Index` is present, matches and submatches are identified by byte index pairs within the input string.
6767

@@ -73,8 +73,8 @@ There are also methods for:
7373
All-in-all, the `regexp` package defines more than 40 functions and methods.
7474
We will demonstrate the use of a few methods below.
7575
Please see the [API documentation][package-regexp] for details of these and other functions.
76-
77-
### `MatchString` Examples
76+
77+
### `MatchString` Examples
7878

7979
Method `MatchString` reports whether a string contains any match of a regular expression.
8080

@@ -83,10 +83,10 @@ re = regexp.MustCompile(`[a-z]+\d*`)
8383
b = re.MatchString("[a12]") // => true
8484
b = re.MatchString("12abc34(ef)") // => true
8585
b = re.MatchString(" abc!") // => true
86-
b = re.MatchString("123 456") // => false
86+
b = re.MatchString("123 456") // => false
8787
```
8888

89-
### `FindString` Examples
89+
### `FindString` Examples
9090

9191
Method `FindString` returns a string holding the text of the leftmost match of the regular expression.
9292

@@ -104,7 +104,7 @@ Method `FindStringSubmatch` returns a slice of strings holding the text of the l
104104
This can be used to identify the strings matching capturing groups.
105105
A return value of `nil` indicates no match.
106106

107-
```go
107+
```go
108108
re = regexp.MustCompile(`[a-z]+(\d*)`)
109109
sl = re.FindStringSubmatch("[a12]") // => []string{"a12","12"}
110110
sl = re.FindStringSubmatch("12abc34(ef)") // => []string{"abc34","34"}
@@ -123,9 +123,9 @@ s = re.ReplaceAllString("12abc34(ef)", "X") // => "12X(X)"
123123
s = re.ReplaceAllString(" abc!", "X") // => " X!"
124124
s = re.ReplaceAllString("123 456", "X") // => "123 456"
125125
```
126-
126+
127127
### `Split` Examples
128-
128+
129129
Method `re.Split(s,n)` slices a text `s` into substrings separated by the expression and returns a slice of the substrings between those expression matches.
130130
The count `n` determines the maximal number of substrings to return.
131131
If `n<0`, the method returns all substrings.
@@ -137,6 +137,6 @@ sl = re.Split("12abc34(ef)", 2) // => []string{"12","(ef)"}
137137
sl = re.Split(" abc!", -1) // => []string{" ","!"}
138138
sl = re.Split("123 456", -1) // => []string{"123 456"}
139139
```
140-
140+
141141
[package-regexp]: https://pkg.go.dev/regexp
142142
[regexp-syntax]: https://pkg.go.dev/regexp/syntax

0 commit comments

Comments
 (0)