Joni

Java port of Oniguruma: http://www.geocities.jp/kosako3/oniguruma that uses byte arrays directly instead of java Strings and chars

License

License

GroupId

GroupId

io.airlift
ArtifactId

ArtifactId

joni
Last Version

Last Version

2.1.5.3
Release Date

Release Date

Type

Type

jar
Description

Description

Joni
Java port of Oniguruma: http://www.geocities.jp/kosako3/oniguruma that uses byte arrays directly instead of java Strings and chars
Source Code Management

Source Code Management

https://github.com/airlift/joni

Download joni

How to add to project

<!-- https://jarcasting.com/artifacts/io.airlift/joni/ -->
<dependency>
    <groupId>io.airlift</groupId>
    <artifactId>joni</artifactId>
    <version>2.1.5.3</version>
</dependency>
// https://jarcasting.com/artifacts/io.airlift/joni/
implementation 'io.airlift:joni:2.1.5.3'
// https://jarcasting.com/artifacts/io.airlift/joni/
implementation ("io.airlift:joni:2.1.5.3")
'io.airlift:joni:jar:2.1.5.3'
<dependency org="io.airlift" name="joni" rev="2.1.5.3">
  <artifact name="joni" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.airlift', module='joni', version='2.1.5.3')
)
libraryDependencies += "io.airlift" % "joni" % "2.1.5.3"
[io.airlift/joni "2.1.5.3"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 3.8.1

Project Modules

There are no modules declared in this project.

joni

Java port of Oniguruma regexp library

Usage

Imports

    import org.jcodings.specific.UTF8Encoding;
    import org.joni.Matcher;
    import org.joni.Option;
    import org.joni.Regex;

Matching

    
    byte[] pattern = "a*".getBytes();
    byte[] str = "aaa".getBytes();

    Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
    Matcher matcher = regex.matcher(str);
    int result = matcher.search(0, str.length, Option.DEFAULT);

Using captures

  byte[] pattern = "(a*)".getBytes();
  byte[] str = "aaa".getBytes();

  Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
  Matcher matcher = regex.matcher(str);
  int result = matcher.search(0, str.length, Option.DEFAULT);
  if (result != -1) {
      Region region = matcher.getEagerRegion();
  }

Using named captures

  byte[] pattern = "(?<name>a*)".getBytes();
  byte[] str = "aaa".getBytes();

  Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
  Matcher matcher = regex.matcher(str);
  int result = matcher.search(0, str.length, Option.DEFAULT);
  if (result != -1) {
      Region region = matcher.getEagerRegion();
      for (Iterator<NameEntry> entry = regex.namedBackrefIterator(); entry.hasNext();) {
          NameEntry e = entry.next();
          int number = e.getBackRefs()[0]; // can have many refs per name
          // int begin = region.beg[number];
          // int end = region.end[number];

      }
  }

License

Joni is released under the MIT License.

io.airlift

Versions

Version
2.1.5.3
2.1.5.2
2.1.5.1