Skip to content

vlang/pcre

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 31, 2025
fdf46a1 · Jan 31, 2025

History

65 Commits
Oct 26, 2024
Jan 11, 2023
Oct 26, 2024
Jan 10, 2023
Jan 10, 2023
Jan 10, 2023
Dec 15, 2020
Jan 16, 2025
Mar 18, 2023
Dec 1, 2023
Jan 31, 2025
Apr 6, 2023
Jan 16, 2025

Repository files navigation

pcre

A simple regex library for V.

Installation

You can install this module using v install pcre, and then use it with import pcre .

When there are updates, you can update with v update pcre .

You can also just run v install pcre again.

Example

(this can also be found in examples/match_after.v)

# examples/match_after.v

import pcre

fn main() {
  r := pcre.new_regex('Match everything after this: (.+)', 0) or {
    println('An error occured!')
    return
  }

  m := r.match_str('Match everything after this: "I <3 VLang!"', 0, 0) or {
    println('No match!')
    return
  }

  // m.get(0) -> Match everything after this: "I <3 VLang!"
  // m.get(1) -> "I <3 VLang!"'
  // m.get(2) -> Error!
  whole_match := m.get(0) or {
    println('We matched nothing...')
    return
  }

  matched_str := m.get(1) or {
    println('We matched nothing...')
    return
  }

  println(whole_match) // Match everything after this: "I <3 VLang!"
  println(matched_str) // "I <3 VLang!"

  r.free()
}
> v -o example examples/match_after.v
> ./example
Match everything after this: "I <3 VLang!"
"I <3 VLang!"

Usage

Some examples are available in the examples directory.

Built With

  • PCRE - Perl Compatible Regular Expressions
  • Vlang - Simple, fast, safe, compiled language

License

MIT

Contributors

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published