@@ -134,7 +134,7 @@ The dot is a particular meta-char, that matches "any char".
134
134
It is simpler to explain it with an example:
135
135
136
136
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
138
138
parsing source string.
139
139
140
140
| query string | result |
@@ -299,8 +299,8 @@ The `.group_csave` array will be filled then, following this logic:
299
299
300
300
` re.group_csave[0] ` - number of total saved records
301
301
` 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
304
304
305
305
The regex will save groups, until it finishes, or finds that the array has no
306
306
more space. If the space ends, no error is raised, and further records will
@@ -506,8 +506,8 @@ re.flag = regex.f_bin
506
506
507
507
### Initializer
508
508
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.
511
511
512
512
#### ** Simplified initializer**
513
513
@@ -519,7 +519,7 @@ pub fn regex_opt(in_query string) ?RE
519
519
#### ** Base initializer**
520
520
521
521
``` 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
523
523
pub fn new() RE
524
524
```
525
525
@@ -528,8 +528,8 @@ pub fn new() RE
528
528
After an initializer is used, the regex expression must be compiled with:
529
529
530
530
``` 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) !
533
533
```
534
534
535
535
### Matching Functions
@@ -557,7 +557,7 @@ pub fn (mut re RE) find(in_txt string) (int, int)
557
557
// the matches are [3,4] and [6,8]
558
558
pub fn (mut re RE) find_all(in_txt string) []int
559
559
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
561
561
// return a list of strings
562
562
// the result is like ['first match','secon match']
563
563
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
567
567
568
568
``` v ignore
569
569
// 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
571
571
pub fn (mut re RE) replace(in_txt string, repl string) string
572
572
```
573
573
0 commit comments