regexp man page on Plan9

Man page or keyword search:  
man Server   549 pages
apropos Keyword Search (all sections)
Output format
Plan9 logo
[printable version]

REGEXP(2)							     REGEXP(2)

NAME
       regcomp,	 regcomplit,  regcompnl,  regexec,  regsub, rregexec, rregsub,
       regerror - regular expression

SYNOPSIS
       #include <u.h>
       #include <libc.h>
       #include <regexp.h>

       Reprog  *regcomp(char *exp)

       Reprog  *regcomplit(char *exp)

       Reprog  *regcompnl(char *exp)

       int  regexec(Reprog *prog, char *string, Resub *match, int msize)

       void regsub(char *source, char *dest, int dlen, Resub *match, int msize)

       int  rregexec(Reprog *prog, Rune *string, Resub *match, int msize)

       void rregsub(Rune *source, Rune *dest, int dlen, Resub *match, int msize)

       void regerror(char *msg)

DESCRIPTION
       Regcomp compiles a regular expression and returns a pointer to the gen‐
       erated  description.   The  space  is allocated by malloc(2) and may be
       released by free.  Regular expressions are exactly as in regexp(6).

       Regcomplit is like regcomp except that all characters are treated  lit‐
       erally.	 Regcompnl  is	like  regcomp except that the .	 metacharacter
       matches all characters, including newlines.

       Regexec matches a null-terminated string against the  compiled  regular
       expression  in prog.  If it matches, regexec returns 1 and fills in the
       array match with character pointers to the substrings  of  string  that
       correspond  to  the  parenthesized  subexpressions  of exp: match[i].sp
       points to the beginning and match[i].ep points just beyond the  end  of
       the  ith	 substring.  (Subexpression i begins at the ith left parenthe‐
       sis, counting from 1.)  Pointers in match[0]  pick  out	the  substring
       that  corresponds  to the whole regular expression.  Unused elements of
       match are filled with zeros.  Matches involving and are extended as far
       as  possible.  The number of array elements in match is given by msize.
       The structure of elements of match is:

	      typedef struct {
		      union {
			 char *sp;
			 Rune *rsp;
		      };
		      union {
			 char *ep;
			 Rune *rep;
		      };
	      } Resub;

       If match[0].sp is nonzero on entry, regexec  starts  matching  at  that
       point  within  string.	If  match[0].ep	 is nonzero on entry, the last
       character matched is the one preceding that point.

       Regsub places in dest a substitution instance of source in the  context
       of  the last regexec performed using match.  Each instance of \n, where
       n is a digit, is replaced by the string delimited  by  match[n].sp  and
       match[n].ep.   Each  instance of is replaced by the string delimited by
       match[0].sp and match[0].ep.  The substitution will always be null ter‐
       minated and trimmed to fit into dlen bytes.

       Regerror,  called  whenever an error is detected in regcomp, writes the
       string msg on the standard error	 file  and  exits.   Regerror  can  be
       replaced	 to  perform  special  error processing.  If the user supplied
       regerror returns rather than exits, regcomp will return 0.

       Rregexec and rregsub are	 variants  of  regexec	and  regsub  that  use
       strings of Runes instead of strings of chars.  With these routines, the
       rsp and rep fields of the match array elements should be used.

SOURCE
       /sys/src/libregexp

SEE ALSO
       grep(1)

DIAGNOSTICS
       Regcomp returns 0 for an illegal expression or other failure.   Regexec
       returns 0 if string is not matched.

BUGS
       There  is  no  way  to specify or match a NUL character; NULs terminate
       patterns and strings.

								     REGEXP(2)
[top]
                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server Plan9

List of man pages available for Plan9

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net