Skip to content

ft_regex

Mohammed Merabet edited this page Nov 3, 2018 · 6 revisions

Rethinking regular expressions

Regular expressions are an important aspect of parsing, and they make things so easy.

This function has been implemented in this library because of the 42sh project, which is mainly about parsing and lexing.

The 42h project uses an old version of the ft_regex library, the new one can be found here, a full documentation of what is a regular expression and what is the ft_regex library is already mentioned in it, so this page wont go far as you can expect.

man ft_regex

ft_regex is a regex engine for testing search patterns on string subjects.

#include "libft/includes/ft_regex.h"

int ft_regex(int flags, const char *regex, const char *subject, ...);
int ft_print_matches(const char *subject, t_list *matches);

The ft_regex function will perform a search on subject based on the regex pattern. If the search fails, the function returns -1, otherwise, if it succeeds, it returns the number of matched characters.

A full documention of this library can be found here

Clone this wiki locally