Skip to content

Commit f3cdd9e

Browse files
authored
Update README.md with back option
1 parent f8a1701 commit f3cdd9e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@ Fortran-regex is a Modern Fortran port of the [tiny-regex-c](https://github.com/
77
The main API is modelled around Fortran's `index` intrinsic function (which performs a simple search for a substring within a string):
88

99
```fortran
10-
! Simple regex
11-
result = REGEX(string, pattern)
12-
13-
! Regex with output matched pattern length
14-
result = REGEX(string, pattern, length)
10+
! Perform regex on a character string
11+
result = REGEX(string, pattern [, length] [, [back]])
1512
```
16-
1713
- If the pattern command is invalid, `result = -1`.
1814
- If no substrings with the given pattern are found, with a valid pattern `result = 0`. This is also returned if the string has zero length, and that is an acceptable answer for the input pattern.
19-
- Otherwise, if the pattern was found `result > 0` equal to the leftmost location inside the string where the pattern can be found. `length` returns the number of consecutive characters that match this pattern
15+
- Otherwise, if the pattern was found `result > 0` equal to the leftmost location inside the string where the pattern can be found. If the `back` keyword is provided and `.true.`, the location of the rightmost occurrence is returned instead. `length` returns the number of consecutive characters that match this pattern
16+
17+
### Arguments
18+
19+
| Argument | Type | Intent | Description |
20+
| --- | --- | --- | --- |
21+
| `string` | `character(*)` | `in` | The input text |
22+
| `pattern` | `character(*)` | `in` | The regex command |
23+
| `length` | `integer` | `out` (optional) | Length of the matched pattern |
24+
| `back` | `logical` | `in` (optional) | If the BACK argument is present and `.true.`, the return value is the start of the last occurrence rather than the first. |
25+
26+
2027

2128
### Object-oriented interface
2229

0 commit comments

Comments
 (0)