Server Data Formatters - Text

Intro

Below is a comprehensive list of Text data formatters available in Server Connect, accompanied by explanations outlining the purpose and functionality of each.

Text Formatters

Convert To Lowercase:

  • Converts the given value to lowercase using UTF-8 encoding.
  • Example: ('Hello World').lowercase() returns 'hello world'

Convert To Uppercase:

  • Converts the given value to uppercase using UTF-8 encoding.
  • Example: ('Hello World').uppercase() returns 'HELLO WORLD'

Camelize String:

  • Converts the given value to camelCase format, removing spaces and certain characters and capitalizing each word's first letter.
  • Example: ('hello world example').camelize() returns 'helloWorldExample'

Capitalize String:

  • Converts the first character of the given value to uppercase using UTF-8 encoding.
  • Example: ('hello world').capitalize() returns 'Hello world'

Dasherize String:

  • Converts the given value to dasherized format, replacing spaces and certain characters with dashes.
  • Example: ('Hello World Example').dasherize() returns 'hello-world-example'

Humanize String:

  • Converts the given value to human-readable format, replacing underscores and certain characters with spaces and capitalizing the first letter.
  • Example: ('example_text').humanize() returns 'Example text'

Slugify String:

  • Converts the given value to a URL-friendly slug, replacing non-word characters with dashes.
  • Example: ('Hello World Example!').slugify() returns 'hello-world-example'

Underscore String:

  • Converts the given value to underscore-separated format, replacing spaces and certain characters with underscores.
  • Example: ('Hello World Example').underscore() returns 'hello_world_example'

Titlecase String:

  • Converts the given value to title case, capitalizing the first letter of each word.
  • Example: ('hello world example').titlecase() returns 'Hello World Example'

Camelcase String:

  • Converts the given value to camelCase format, removing spaces and capitalizing each word's first letter except the first one.
  • Example: ('hello world example').camelcase() returns 'helloWorldExample'

Replace String:

  • Replaces occurrences of a search string with a replacement string in the given value.
  • Example: ('Hello World').replace('World', 'Universe') returns 'Hello Universe'

Trim String:

  • Removes leading and trailing whitespace from the given value.
  • Example: (' hello world ').trim() returns 'hello world'

Split String:

  • Splits the given value into an array of substrings using a specified delimiter.
  • Example: ('apple,banana,orange').split(',') returns ['apple', 'banana', 'orange']

Pad String:

  • Pads the given value to a certain length with a specified character and position.
  • Example: ('42').pad(5, '0', 'left') returns '00042'

Repeat String:

  • Repeats the given value a specified number of times.
  • Example: ('hello').repeat(3) returns 'hellohellohello'

Sub String:

  • Extracts a substring from the given value.
  • Example: ('Hello World').substr(6, 5) returns 'World'

Truncate String:

  • Truncates the given value to a specified length, optionally preserving whole words and adding an ellipsis.
  • Example: ('Lorem ipsum dolor sit amet').trunc(15, true) returns 'Lorem ipsum...'

Strip Tags:

  • Removes HTML and PHP tags from the given value.
  • Example: ('<p>Hello</p>').stripTags() returns 'Hello'

Word Count:

  • Counts the number of words in the given value.
  • Example: ('The quick brown fox').wordCount() returns 4

Length:

  • Returns the length (number of characters) of the given value using UTF-8 encoding.
  • Example: ('Hello World').length() returns 11

URL Encode:

  • Encodes the given value as a URL-encoded string.
  • Example: ('Hello World!').urlencode() returns 'Hello%20World%21'
9 Likes