You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-7Lines changed: 14 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,23 @@ Fortran-regex is a Modern Fortran port of the [tiny-regex-c](https://github.com/
7
7
The main API is modelled around Fortran's `index` intrinsic function (which performs a simple search for a substring within a string):
8
8
9
9
```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]])
15
12
```
16
-
17
13
- If the pattern command is invalid, `result = -1`.
18
14
- 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. |
0 commit comments