Next: 4.10.30 nxo_stack Up: 4.10 Classes Previous: 4.10.28 nxo_regex Contents Index
Subsections

- 4.10.29.1 API

##
4.10.29 nxo_regsub

The nxo_regsub class is a subclass of the nxo class.

### 4.10.29.1 API

cw_nxn_t nxo_regsub_new(cw_nxo_t *a_nxo, cw_nx_t *a_nx, const cw_uint8_t *a_pattern, cw_uint32_t a_plen, cw_bool_t a_global, cw_bool_t a_insensitive, cw_bool_t a_multiline, cw_bool_t a_singleline, const cw_uint8_t *a_template, cw_uint32_t a_tlen):

  Input(s):
    a_nxo:
      Pointer to a regsub nxo.
    a_nx:
      Pointer to an nx.
    a_pattern:
      Pointer to a string that specifies a regular expression.
    a_plen:
      Length of a_pattern.
    a_global:
      Substitute as many times as possible if TRUE.
    a_insensitive:
      Match with case insensitivity if TRUE.
    a_multiline:
      Treat input as a multi-line string if TRUE.
    a_singleline:
      Treat input as a single line, so that the dot metacharacter matches any character, including a newline.
    a_template:
      Pointer to a string that specifies a substitution template.
    a_tlen:
      Length of a_template.
  Output(s):
    retval:
      NXN_ZERO:
        Success.
      NXN_regexerror:
        Regular expression error.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Constructor.

void nxo_regsub_subst(cw_nxo_t *a_nxo, cw_nxo_t *a_thread, cw_nxo_t *a_input, cw_nxo_t *r_output, cw_uint32_t *r_count):

  Input(s):
    a_nxo:
      Pointer to a regsub nxo.
    a_thread:
      Pointer to a thread nxo.
    a_input:
      Pointer to a string nxo.
    r_output:
      Pointer to an nxo to dup a string reference to.
    r_count:
      Pointer to a cw_uint32_t .
  Output(s):
    *r_output:
      A string that was created by substituting regular expression matches according to a substitution template.
    *r_count:
      Number of substitutions made. If 0 substitutions were made, *r_output is a duplicate of a_input, rather than a copy.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Create a string by substituting according to a_template for each substring within input that matches a regular expression.

    As a side effect, set the thread's match cache, which can be queried via nxo_regex_submatch().

cw_nxn_t nxo_regsub_nonew_subst(cw_nxo_t *a_thread, const cw_uint8_t *a_pattern, cw_uint32_t a_plen, cw_bool_t a_global, cw_bool_t a_insensitive, cw_bool_t a_multiline, cw_bool_t a_singleline, const cw_uint8_t *a_template, cw_uint32_t a_tlen, cw_nxo_t *a_input, cw_nxo_t *r_output, cw_uint32_t *r_count):

  Input(s):
    a_thread:
      Pointer to a thread nxo.
    a_pattern:
      Pointer to a string that specifies a regular expression.
    a_plen:
      Length of a_pattern.
    a_global:
      Substitute as many times as possible if TRUE.
    a_insensitive:
      Match with case insensitivity if TRUE.
    a_multiline:
      Treat input as a multi-line string if TRUE.
    a_singleline:
      Treat input as a single line, so that the dot metacharacter matches any character, including a newline.
    a_template:
      Pointer to a string that specifies a substitution template.
    a_tlen:
      Length of a_template.
    a_input:
      Pointer to a string nxo.
    r_output:
      Pointer to an nxo to dup a string reference to.
    r_count:
      Pointer to a cw_uint32_t .
  Output(s):
    retval:
      NXN_ZERO:
        Success.
      NXN_regexerror:
        Regular expression error.
    *r_output:
      A string that was created by substituting regular expression matches (specified by a_pattern) according to a_template.
    *r_count:
      Number of substitutions made. If 0 substitutions were made, *r_output is a duplicate of a_input, rather than a copy.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Create a string by substituting according to a_template for each substring within input that matches a regular expression.

    As a side effect, set the thread's match cache, which can be queried via nxo_regex_submatch().

    This function combines nxo_regsub_new() and nxo_regsub_subst() in such a way that no Onyx regsub object is created, thus providing a more efficient way of doing a one-off subst.

Next: 4.10.30 nxo_stack Up: 4.10 Classes Previous: 4.10.28 nxo_regex Contents Index