Skip to content

Commit

Permalink
Merge branch 'master' into invalid-unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
headius authored Jan 15, 2025
2 parents 3a4a222 + a8bdae1 commit 18932fc
Show file tree
Hide file tree
Showing 40 changed files with 938 additions and 859 deletions.
57 changes: 40 additions & 17 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,54 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# For more information see:
# - https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-maven
# - https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Java CI with Maven

on:
push:
branches: [ "master" ]
branches-ignore: # build all branches except:
- 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR)
tags-ignore: # don't build tags
- '**'
paths-ignore:
- 'Jenkinsfile'
- 'LICENSE'
- '**/*.md'
- '.git*'
- '.github/*.yml'
pull_request:
branches: [ "master" ]
paths-ignore:
- 'Jenkinsfile'
- 'LICENSE'
- '**/*.md'
- '.git*'
- '.github/*.yml'
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/


defaults:
run:
shell: bash


jobs:
build:

runs-on: ubuntu-latest

env:
JAVA_VERSION: 11

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- name: Git Checkout
uses: actions/checkout@v4 # https://github.com/actions/checkout

- name: Set up JDK ${{ env.JAVA_VERSION }} ☕
uses: actions/setup-java@v4 # https://github.com/actions/setup-java
with:
java-version: '11'
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Build with Maven 🔨
run: mvn -ntp -B verify
Binary file removed .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
20 changes: 19 additions & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
2 changes: 0 additions & 2 deletions MANIFEST.MF

This file was deleted.

87 changes: 43 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,66 @@
joni
====

[![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)
[![Build Status](https://github.com/jruby/joni/workflows/Java%20CI%20with%20Maven/badge.svg?branch=master)](https://github.com/jruby/joni/actions)
[![Maven Central](https://img.shields.io/maven-central/v/org.jruby.joni/joni)](https://central.sonatype.com/artifact/org.jruby.joni/joni)
[![Build Status](https://github.com/jruby/joni/actions/workflows/maven.yml/badge.svg)](https://github.com/jruby/joni/actions/workflows/maven.yml)

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

## Usage

### Imports
```java
import org.jcodings.specific.UTF8Encoding;
import org.joni.Matcher;
import org.joni.Option;
import org.joni.Regex;
```

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

### Matching

```java

byte[] pattern = "a*".getBytes();
byte[] str = "aaa".getBytes();
```java
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);
```
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

```java
byte[] pattern = "(a*)".getBytes();
byte[] str = "aaa".getBytes();
```java
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();
}
```
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

```java
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];

}
```java
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

Expand Down
Loading

0 comments on commit 18932fc

Please sign in to comment.