---
name: "Ns_Match"
section: "3"
platform: "linux"
package: "aolserver4"
version: "4.0.10-7"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_String"
---

# Ns\_Match(3)

library procedures

Part of [Ns\_String(3)](/Ns_String/3.md).

```

```

## NAME

Ns\_Match, Ns\_NextWord, Ns\_StrCaseFind, Ns\_StrCopy, Ns\_StrDup, Ns\_StrNStr, Ns\_StrToLower, Ns\_StrToUpper, Ns\_StrTrim, Ns\_StrTrimLeft, Ns\_StrTrimRight, Ns\_StringPrint, ns\_strcopy, ns\_strdup - library procedures

## SYNOPSIS

```
#include "ns.h"

char *
Ns_Match(char *a, char *b)

char *
Ns_NextWord(char *line)

char *
Ns_StrCaseFind(char *s1, char *s2)

char *
Ns_StrCopy(char *str)
ns_strcopy(char *str)

char *
Ns_StrDup(char *str)
ns_strdup(char *str)

char *
Ns_StrNStr(char *pattern, char *expression)

char *
Ns_StrToLower(char *string)

char *
Ns_StrToUpper(char *string)

char *
Ns_StrTrim(char *string)

char *
Ns_StrTrimLeft(char *string)

char *
Ns_StrTrimRight(char *string)

void
Ns_StringPrint(char *string)
```

## DESCRIPTION

- **Ns\_Match**(*a, b*)

  Compare the beginnings of two strings, case insensitively.  The comparison stops when the end of the shorter string is reached. Return NULL if no match, b if match.

- **Ns\_NextWord**(*line*)

  Return a pointer to first character of the next word in a  string; words are separated by white space.  The returned pointer points into the original string. For example, Ns\_NextWord("abc def") returns a pointer to the 'd' in that string.

- **Ns\_StrCaseFind**(*s1, s2*)

  Locate the first occurrence of substring s2 within string s1  in a case-insensitive manner. The terminating ' '  characters are not compared. Returns a pointer that points into s1. Uses [strstr(3)](/strstr/3.md) to do its work.

- **Ns\_StrCopy**(*str*)

  **ns\_strcopy**(*str*)

  Copy a string or NULL value using Ns\_Malloc. The Ns\_StrCopy function is identical to the Ns\_StrDup function but allows for the string parameter to be NULL, in which case Ns\_StrCopy does nothing and returns NULL.

- **Ns\_StrDup**(*str*)

  **ns\_strdup**(*str*)

  Copy a string using Ns\_Malloc. The Ns\_StrDup function calls Ns\_Malloc to allocate enough memory to make a copy of the given string.

- **Ns\_StrNStr**(*pattern, expression*)

  Search through pattern for expression, case insensitively. Return a pointer that points to where the match begins within pattern, or NULL if expression is not contained in pattern.

- **Ns\_StrToLower**(*string*)

  Convert string to lowercase. Returns pointer to original string. Original string will be modified.

- **Ns\_StrToUpper**(*string*)

  Convert string to uppercase. Returns pointer to original string. Original string will be modified.

- **Ns\_StrTrim**(*string*)

  Trim leading and trailing white space from string. A pointer to the trimmed string will be returned, which will be in the original string. Do not lose your original pointer to the string if you later need to free it.

- **Ns\_StrTrimLeft**(*string*)

  Trim leading white space from string. A pointer to the trimmed string will be returned, which will be in the original string. Do not lose your original pointer to the string if you later need to free it.

- **Ns\_StrTrimRight**(*string*)

  Trim trailing white space from string. The original string pointer will be returned, but the string will have been modified: a ' 's will have been placed right after the last non-whitespace character of the string.

- **Ns\_StringPrint**(*string*)

  Print a string to stdout.

## SEE ALSO

nsd(1), [info(n)](/info/n.md)

## KEYWORDS
