{"id":18847791,"url":"https://github.com/interkosmos/fortran-pcre2","last_synced_at":"2026-01-27T15:32:44.035Z","repository":{"id":139286061,"uuid":"431224948","full_name":"interkosmos/fortran-pcre2","owner":"interkosmos","description":"Fortran 2018 interface bindings to PCRE2","archived":false,"fork":false,"pushed_at":"2025-03-19T13:16:39.000Z","size":30,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-23T00:33:55.387Z","etag":null,"topics":["fortran","fortran-2018","fortran-package-manager","fpm","pcre","pcre2","regex","regexp"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interkosmos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-11-23T19:16:38.000Z","updated_at":"2025-03-19T13:16:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"e6997adb-f6a6-4c15-8661-9229289a57e0","html_url":"https://github.com/interkosmos/fortran-pcre2","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/interkosmos/fortran-pcre2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-pcre2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-pcre2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-pcre2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-pcre2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interkosmos","download_url":"https://codeload.github.com/interkosmos/fortran-pcre2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-pcre2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28815406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fortran","fortran-2018","fortran-package-manager","fpm","pcre","pcre2","regex","regexp"],"created_at":"2024-11-08T03:09:42.070Z","updated_at":"2026-01-27T15:32:44.030Z","avatar_url":"https://github.com/interkosmos.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fortran-pcre2\n\nA work-in-progress collection of Fortran 2018 ISO_C_BINDING interfaces to\nPerl-compatible Regular Expressions 2\n([PCRE2](https://www.pcre.org/current/doc/html/)). The library is also available\non [MacPorts](https://ports.macports.org/port/fortran-pcre2/).\n\n## Build Instructions\n\nYou will need *libpcre2* with development headers. On FreeBSD, run:\n\n```\n# pkg install devel/pcre2\n```\n\nOn Debian Linux, install:\n\n```\n# apt-get install libpcre2-8-0 libpcre2-dev\n```\n\nClone the repository and execute the provided `Makefile` to create the static\nlibrary `libfortran-pcre2.a` containing the interfaces:\n\n```\n$ git clone https://github.com/interkosmos/fortran-pcre2\n$ cd fortran-pcre2/\n$ make\n```\n\nInstall the library and the modules files system-wide to `/opt`:\n\n```\n$ make install PREFIX=/opt\n```\n\nInstead of `make`, you may want to build the library using the Fortran Package\nManager:\n\n```\n$ fpm build --profile release\n```\n\nLink your Fortran programs against `libfortran-pcre2.a` and `-lpcre2-8`.\n\n## Example\n\nThe following program just compiles and executes a basic regular expression.\n\n```fortran\n! example.f90\nprogram main\n    use :: pcre2\n    implicit none (type, external)\n\n    integer, parameter :: OVECSIZE = 30 ! Must be multiple of 3.\n\n    character(len=128)            :: buffer\n    character(len=:), allocatable :: pattern, subject\n    integer                       :: err_code, rc\n    integer(kind=pcre2_size)      :: err_offset\n    type(c_ptr)                   :: match_data, re\n\n    pattern = '^([A-Z][a-z]+)$'\n    subject = 'Fortran'\n\n    ! Compile regular expression.\n    re = pcre2_compile(pattern     = pattern, \u0026\n                       length      = len(pattern, kind=pcre2_size), \u0026\n                       options     = 0, \u0026\n                       errorcode   = err_code, \u0026\n                       erroroffset = err_offset, \u0026\n                       ccontext    = c_null_ptr)\n\n    if (.not. c_associated(re)) then\n        buffer = ' '\n        rc = pcre2_get_error_message(err_code, buffer, len(buffer, kind=pcre2_size))\n        print '(\"Error \", i0, \": \", a)', err_code, trim(buffer)\n        stop\n    end if\n\n    ! Execute regular expression.\n    match_data = pcre2_match_data_create(OVECSIZE, c_null_ptr)\n\n    rc = pcre2_match(code        = re, \u0026\n                     subject     = subject, \u0026\n                     length      = len(subject, kind=pcre2_size), \u0026\n                     startoffset = int(0, kind=pcre2_size), \u0026\n                     options     = 0, \u0026\n                     match_data  = match_data, \u0026\n                     mcontext    = c_null_ptr)\n\n    if (rc == 0) then\n        print '(\"OVECSIZE too small\")'\n    else if (rc \u003c 0) then\n        select case (rc)\n            case (PCRE2_ERROR_NOMATCH)\n                print '(\"No match\")'\n            case default\n                print '(\"Matching error \", i0)', rc\n        end select\n    else if (rc \u003e 0) then\n        print '(\"Match!\")'\n    end if\n\n    call pcre2_match_data_free(match_data)\n    call pcre2_code_free(re)\nend program main\n```\n\nIf the library has been installed to `/opt`, then compile, link, and run the\nprogram with:\n\n```\n$ gfortran -I/opt/include/libfortran-pcre2 -o example example.f90 /opt/lib/libfortran-pcre2.a -lpcre2-8\n$ ./example\n```\n\n## Fortran Package Manager\n\nYou can add *fortran-pcre2* as an [FPM](https://github.com/fortran-lang/fpm)\ndependency:\n\n```toml\n[dependencies]\nfortran-pcre2 = { git = \"https://github.com/interkosmos/fortran-pcre2.git\" }\n```\n\n## Compatibility\n\nIt is not necessary to null-terminate character strings given to the procedures\nof *fortran-pcre2*. In contrast to the C API of PCRE2, you must not free\nsubstrings with `pcre2_substring_free()`, as this will be done by the wrapper\nfunctions.\n\n## Coverage\n\n| C API                                | Fortran interface                   |\n|--------------------------------------|-------------------------------------|\n| `pcre2_code_free_8`                  |  `pcre2_code_free`                  |\n| `pcre2_compile_8`                    |  `pcre2_compile`                    |\n| `pcre2_compile_context_free_8`       |  `pcre2_compile_context_free`       |\n| `pcre2_get_error_message_8`          |  `pcre2_get_error_message`          |\n| `pcre2_get_ovector_count_8`          |  `pcre2_get_ovector_count`          |\n| `pcre2_get_ovector_pointer_8`        |  `pcre2_get_ovector_pointer`        |\n| `pcre2_match_8`                      |  `pcre2_match`                      |\n| `pcre2_match_data_create_8`          |  `pcre2_match_data_create`          |\n| `pcre2_match_data_free_8`            |  `pcre2_match_data_free`            |\n| `pcre2_substring_copy_byname_8`      |  `pcre2_substring_copy_byname`      |\n| `pcre2_substring_copy_bynumber_8`    |  `pcre2_substring_copy_bynumber`    |\n| `pcre2_substring_free_8`             |  `pcre2_substring_free`             |\n| `pcre2_substring_get_byname_8`       |  `pcre2_substring_get_byname`       |\n| `pcre2_substring_get_bynumber_8`     |  `pcre2_substring_get_bynumber`     |\n| `pcre2_substring_number_from_name_8` |  `pcre2_substring_number_from_name` |\n\n## Licence\n\nISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterkosmos%2Ffortran-pcre2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterkosmos%2Ffortran-pcre2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterkosmos%2Ffortran-pcre2/lists"}