# String `[Shared]`

The String module extends Lua's native string capabilities by adding powerful utility functions for enhanced string manipulation. It seamlessly integrates with the standard string library by augmenting the string metatable, providing developers with a comprehensive toolkit for case conversion, string splitting, whitespace trimming, version number handling, and hexadecimal conversions.

## string Methods

### string:compareVersionWith()

Compare two version strings <br>

#### Syntax

```lua
string:compareVersionWith(version)
```

#### Parameters

`version` : _string_
> The string version to compare to
>

#### Return Value

Type : _integer_

> `-1` if the version is older, `0` if it's the same and `1` if it's more recent

---

### string:convertVersion()

Convert a version string (like "1.2.3") to a numeric value <br>

#### Syntax

```lua
string:convertVersion()
```

#### Return Value

Type : _number_

> The converted numeric version

---

### string:extractConvarComparator()

Extract resource, convar, comparator and value from a "resourceName[:convar](< > <= >= ==)value" string <br>
The ":convar" part is optional (eg. "rsg-core>=2.0.0") <br>

#### Syntax

```lua
string:extractConvarComparator()
```

#### Return Value

Type : _string?_

---

### string:firstToUpper()

Return the string with the first letter in uppercase <br>

#### Syntax

```lua
string:firstToUpper()
```

#### Return Value

Type : _string_

> Return the string with the first letter in uppercase

---

### string:removeAccent()

A function to remove all accent in a string <br>

#### Syntax

```lua
string:removeAccent()
```

#### Return Value

Type : _string_

> A string without accent

---

### string:split()

Split a string into parts based on a delimiter <br>

#### Syntax

```lua
string:split(delimiter, pieces)
```

#### Parameters

`delimiter` : _string_
> The character(s) to split the string on
>

`pieces` : _number_ `[Optional]`
> The maximum number of pieces to split into
>

#### Return Value

Type : _table_

> Array of string parts

---

### string:toHex()

Convert a hexadecimal string to a number, handling signed values <br>

#### Syntax

```lua
string:toHex()
```

#### Return Value

Type : _number_

> The converted numeric value

---

### string:trim()

Remove whitespace from both ends of a string <br>

#### Syntax

```lua
string:trim()
```

#### Return Value

Type : _string_

> The trimmed string

## String Functions

### string.compare()

A function to compare two strings <br>

#### Syntax

```lua
string.compare(a, b, caseSensitive)
```

#### Parameters

`a` : _string_
> The 1st string
>

`b` : _string_
> The 2nd string
>

`caseSensitive` : _boolean_
> If the compare is case sensitive<br>default: `false`
>

#### Return Value

Type : _integer_

> `-1` if `a` is previous, `0` if both are same and `1` if `a` is after

---

### string.spaceNumber()

Convert a integer|number to a spaced number <br>

#### Syntax

```lua
string.spaceNumber(number, decimal)
```

#### Parameters

`number` : _integer|number_
> The number to convert
>

`decimal` : _integer_ `[Optional]`
> The number of decimal <br> default: 0
>
