Skip to content

Commit 307c5b8

Browse files
authored
regex: fix typos and inconsistencies in the documentation (#21468)
1 parent 2e9b4cf commit 307c5b8

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

vlib/regex/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ The dot is a particular meta-char, that matches "any char".
134134
It is simpler to explain it with an example:
135135

136136
Suppose you have `abccc ddeef` as a source string, that you want to parse
137-
with a regex. The following table show the query strings and the result of
137+
with a regex. The following table shows the query strings and the result of
138138
parsing source string.
139139

140140
| query string | result |
@@ -299,8 +299,8 @@ The `.group_csave` array will be filled then, following this logic:
299299

300300
`re.group_csave[0]` - number of total saved records
301301
`re.group_csave[1+n*3]` - id of the saved group
302-
`re.group_csave[1+n*3]` - start index in the source string of the saved group
303-
`re.group_csave[1+n*3]` - end index in the source string of the saved group
302+
`re.group_csave[2+n*3]` - start index in the source string of the saved group
303+
`re.group_csave[3+n*3]` - end index in the source string of the saved group
304304

305305
The regex will save groups, until it finishes, or finds that the array has no
306306
more space. If the space ends, no error is raised, and further records will
@@ -506,8 +506,8 @@ re.flag = regex.f_bin
506506

507507
### Initializer
508508

509-
These functions are helper that create the `RE` struct,
510-
a `RE` struct can be created manually if you needed.
509+
These functions are helpers that create the `RE` struct.
510+
A `RE` struct can be created manually if needed.
511511

512512
#### **Simplified initializer**
513513

@@ -519,7 +519,7 @@ pub fn regex_opt(in_query string) ?RE
519519
#### **Base initializer**
520520

521521
```v ignore
522-
// new_regex create a REgex of small size, usually sufficient for ordinary use
522+
// new create a RE of small size, usually sufficient for ordinary use
523523
pub fn new() RE
524524
```
525525

@@ -528,8 +528,8 @@ pub fn new() RE
528528
After an initializer is used, the regex expression must be compiled with:
529529

530530
```v ignore
531-
// compile compiles the REgex returning an error if the compilation fails
532-
pub fn (mut re RE) compile_opt(in_txt string) ?
531+
// compile_opt compile RE pattern string, returning an error if the compilation fails
532+
pub fn (mut re RE) compile_opt(pattern string) !
533533
```
534534

535535
### Matching Functions
@@ -557,7 +557,7 @@ pub fn (mut re RE) find(in_txt string) (int, int)
557557
// the matches are [3,4] and [6,8]
558558
pub fn (mut re RE) find_all(in_txt string) []int
559559
560-
// find_all find all the "non overlapping" occurrences of the matching pattern
560+
// find_all_str find all the "non overlapping" occurrences of the match pattern
561561
// return a list of strings
562562
// the result is like ['first match','secon match']
563563
pub fn (mut re RE) find_all_str(in_txt string) []string
@@ -567,7 +567,7 @@ pub fn (mut re RE) find_all_str(in_txt string) []string
567567

568568
```v ignore
569569
// replace return a string where the matches are replaced with the repl_str string,
570-
// this function support groups in the replace string
570+
// this function supports groups in the replace string
571571
pub fn (mut re RE) replace(in_txt string, repl string) string
572572
```
573573

vlib/regex/regex_opt.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn (mut re RE) compile_opt(pattern string) ! {
1717
}
1818
}
1919

20-
// new_regex create a RE of small size, usually sufficient for ordinary use
20+
// new create a RE of small size, usually sufficient for ordinary use
2121
pub fn new() RE {
2222
// init regex
2323
mut re := RE{}

vlib/regex/regex_util.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn (re RE) parsed_replace_string(in_txt string, repl string) string {
472472
}
473473

474474
// replace return a string where the matches are replaced with the repl_str string,
475-
// this function support use groups in the replace string
475+
// this function supports groups in the replace string
476476
pub fn (mut re RE) replace(in_txt string, repl_str string) string {
477477
mut i := 0
478478
mut res := strings.new_builder(in_txt.len)

0 commit comments

Comments
 (0)