https://github.com/shellbear/v-regex
A simple regex library for V
https://github.com/shellbear/v-regex
pcre regex v vlang
Last synced: 11 months ago
JSON representation
A simple regex library for V
- Host: GitHub
- URL: https://github.com/shellbear/v-regex
- Owner: shellbear
- License: mit
- Created: 2019-06-29T21:37:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-30T16:19:52.000Z (over 6 years ago)
- Last Synced: 2024-12-31T21:24:15.781Z (about 1 year ago)
- Topics: pcre, regex, v, vlang
- Language: Verilog
- Homepage:
- Size: 5.86 KB
- Stars: 30
- Watchers: 2
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# v-regex
A simple regex library for [VLang](https://github.com/vlang/v).
It use bindings from the [PCRE](https://www.pcre.org/) library.
## Example
```go
# examples/match_after.v
import regex
fn main() {
r := regex.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()
}
```
```bash
> 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](examples/) directory.
## Built With
* [PCRE](https://www.pcre.org/) - Perl Compatible Regular Expressions
* [Vlang](https://github.com/vlang/v) - Simple, fast, safe, compiled language
## License
[MIT](LICENSE)
## Contributors
* [Shellbear](https://github.com/shellbear) - creator and maintainer