Skip to content

Commit 2b1d2d4

Browse files
authored
Merge pull request #83 from sebthom/docs
docs: update README
2 parents e66cac2 + d3a3492 commit 2b1d2d4

File tree

1 file changed

+43
-44
lines changed

1 file changed

+43
-44
lines changed

README.md

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,66 @@
11
joni
22
====
33

4-
[![Maven Central](https://img.shields.io/maven-central/v/org.jruby.joni/joni.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.jruby.joni%22)
5-
[![Build Status](https://github.com/jruby/joni/workflows/Java%20CI%20with%20Maven/badge.svg?branch=master)](https://github.com/jruby/joni/actions)
4+
[![Maven Central](https://img.shields.io/maven-central/v/org.jruby.joni/joni)](https://central.sonatype.com/artifact/org.jruby.joni/joni)
5+
[![Build Status](https://github.com/jruby/joni/actions/workflows/maven.yml/badge.svg)](https://github.com/jruby/joni/actions/workflows/maven.yml)
66

7-
Java port of Oniguruma regexp library
7+
Java port of [Oniguruma](https://github.com/kkos/oniguruma) regexp library
88

99
## Usage
1010

1111
### Imports
12-
```java
13-
import org.jcodings.specific.UTF8Encoding;
14-
import org.joni.Matcher;
15-
import org.joni.Option;
16-
import org.joni.Regex;
17-
```
12+
13+
```java
14+
import org.jcodings.specific.UTF8Encoding;
15+
import org.joni.Matcher;
16+
import org.joni.Option;
17+
import org.joni.Regex;
18+
```
1819

1920
### Matching
2021

21-
```java
22-
23-
byte[] pattern = "a*".getBytes();
24-
byte[] str = "aaa".getBytes();
22+
```java
23+
byte[] pattern = "a*".getBytes();
24+
byte[] str = "aaa".getBytes();
2525

26-
Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
27-
Matcher matcher = regex.matcher(str);
28-
int result = matcher.search(0, str.length, Option.DEFAULT);
29-
```
26+
Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
27+
Matcher matcher = regex.matcher(str);
28+
int result = matcher.search(0, str.length, Option.DEFAULT);
29+
```
3030

3131
### Using captures
3232

33-
```java
34-
byte[] pattern = "(a*)".getBytes();
35-
byte[] str = "aaa".getBytes();
33+
```java
34+
byte[] pattern = "(a*)".getBytes();
35+
byte[] str = "aaa".getBytes();
3636

37-
Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
38-
Matcher matcher = regex.matcher(str);
39-
int result = matcher.search(0, str.length, Option.DEFAULT);
40-
if (result != -1) {
41-
Region region = matcher.getEagerRegion();
42-
}
43-
```
37+
Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
38+
Matcher matcher = regex.matcher(str);
39+
int result = matcher.search(0, str.length, Option.DEFAULT);
40+
if (result != -1) {
41+
Region region = matcher.getEagerRegion();
42+
}
43+
```
4444

4545
### Using named captures
4646

47-
```java
48-
byte[] pattern = "(?<name>a*)".getBytes();
49-
byte[] str = "aaa".getBytes();
50-
51-
Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
52-
Matcher matcher = regex.matcher(str);
53-
int result = matcher.search(0, str.length, Option.DEFAULT);
54-
if (result != -1) {
55-
Region region = matcher.getEagerRegion();
56-
for (Iterator<NameEntry> entry = regex.namedBackrefIterator(); entry.hasNext();) {
57-
NameEntry e = entry.next();
58-
int number = e.getBackRefs()[0]; // can have many refs per name
59-
// int begin = region.beg[number];
60-
// int end = region.end[number];
61-
62-
}
47+
```java
48+
byte[] pattern = "(?<name>a*)".getBytes();
49+
byte[] str = "aaa".getBytes();
50+
51+
Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
52+
Matcher matcher = regex.matcher(str);
53+
int result = matcher.search(0, str.length, Option.DEFAULT);
54+
if (result != -1) {
55+
Region region = matcher.getEagerRegion();
56+
for (Iterator<NameEntry> entry = regex.namedBackrefIterator(); entry.hasNext();) {
57+
NameEntry e = entry.next();
58+
int number = e.getBackRefs()[0]; // can have many refs per name
59+
// int begin = region.beg[number];
60+
// int end = region.end[number];
6361
}
64-
```
62+
}
63+
```
6564

6665
## License
6766

0 commit comments

Comments
 (0)