diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-09-28 16:54:17 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-09-28 16:54:17 -0700 |
| commit | 32fa022985a87a5f81a0cd1b2e96765b787bf1d8 (patch) | |
| tree | c97a6528ec36e8f3873fc53738aaf6b698803385 | |
| parent | e141e9e2f2b70e1cc447fd25719d6546fd7cfaeb (diff) | |
Updated readme with examples
| -rw-r--r-- | README.md | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -25,6 +25,41 @@ BPEG patterns are a mixture of Parsing Expression Grammar and Regular Expression syntax, with a preference for prefix operators instead of suffix operators. +Pattern | Meaning +-------------------|--------------------- +`pat1 pat2` | `pat1` followed by `pat2` +`pat1 / pat2` | `pat1` if it matches, otherwise `pat2` +`...pat` | Any text up to and including `pat` (including newlines) +`..pat` | Any text up to and including `pat` (except newlines) +`.` | Any single character (except newline) +`$.` | Any single character (including newline) +`^^` | The start of the input +`^` | The start of a line +`$$` | The end of the input +`$` | The end of a line +`__` | Zero or more whitespace characters (including newlines) +`_` | Zero or more whitespace characters (excluding newlines) +`` `c `` | The literal character `c` +`` `a-z `` | The character range `a` through `z` +`\n`, `\033`, `\x0A`, etc. | An escape sequence character +`\x00-xFF` | An escape sequence range (byte `0x00` through `0xFF` here) +`!pat` | `pat` does not match at the current position +`[pat]` | Zero or one occurrences of `pat` (optional pattern) +`5 pat` | Exactly 5 occurrences of `pat` +`2-4 pat` | Between 2 and 4 occurrences of `pat` (inclusive) +`5+ pat` | 5 or more occurrences of `pat` +`0+ pat % sep` | 0 or more occurrences of `pat`, separated by `sep` (e.g. `0+ int % ","` matches `1,2,3`) +`<pat` | `pat` matches just before the current position (backref) +`>pat` | `pat` matches just in front of the current position (lookahead) +`@pat` | Capture `pat` (used for text replacement and backreferences) +`@foo=pat` | Let `foo` be the text of `pat` (used for text replacement and backreferences) +`{pat => "replacement"}` | Match `pat` and replace it with `replacement` +`{pat @other => "@1"}` | Match `pat` followed by `other` and replace it with the text of `other` +`{pat @keep=other => "@keep"}` | Match `pat` followed by `other` and replace it with the text of `other` +`pat1==pat2` | `pat1`, assuming `pat2` also matches with the same length +`#( block comment )#` | A block comment +`# line comment` | A line comment + See `man ./bpeg.1` for more details. ## License |
