Core Function Unescape
From Sputnik Wiki
(Difference between revisions)
Line 38: | Line 38: | ||
Unescape only \t and \n | Unescape only \t and \n | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | say Unescape(@"\nHello\tTest\p \Ok", | + | say Unescape(@"\nHello\tTest\p \Ok", 'tn'); |
// Prints: nHellotTest\p \Ok | // Prints: nHellotTest\p \Ok | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 16:03, 13 September 2013
Unescape( <expression>, <custom> )
Contents |
Description
Remove all escapes from a string.
Parameters
expression
The string to use.
custom
Optional; A string containing characters to be escaped instead of unescaping everything.
Return Value
Success: Returns a string with backslashes stripped off. (\' becomes ' and so on.) Double backslashes (\\) are made into a single backslash (\).
Failure: Returns empty string.
Remarks
This removes all escapes from a string regardless if the escape is valid or not so even \# will be replaced with #.
If you require more specific escape/unescape functions see the ones that deal with C/Sputnik specific escapes.
Example
Unescape everything
say Unescape(@"\m\n\t\\");// Prints: mnt\
Unescape only \t and \n
say Unescape(@"\nHello\tTest\p \Ok", 'tn'); // Prints: nHellotTest\p \Ok