From WikiChip
Editing mirc/string manipulation
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 2: | Line 2: | ||
'''String manipulation''' is the building block of many of today's utilities and algorithms. Everything from formatting and validation to analysis and manipulation requires heavy use of string manipulation. Fortunately for you, the language provides powerful string manipulation facilities. | '''String manipulation''' is the building block of many of today's utilities and algorithms. Everything from formatting and validation to analysis and manipulation requires heavy use of string manipulation. Fortunately for you, the language provides powerful string manipulation facilities. | ||
− | + | I like this site its a master peace ! Glad I observed this on google. The definition of a beautiful woman is one who loves me. by Sloan Wilson. eeadeedkeaeaabde | |
− | |||
− | + | == Substrings == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
A substring is a string that is part of a longer string. There are a number of built-in identifiers that can be used to retrieve a smaller portion of the original string. | A substring is a string that is part of a longer string. There are a number of built-in identifiers that can be used to retrieve a smaller portion of the original string. | ||
=== $left() and $right() === | === $left() and $right() === | ||
+ | |||
The first two identifiers you should be familiar with are the {{mIRC|$left}} and {{mIRC|$right}} identifiers which can be used to return the left or right most part of the original string respectably. Their syntax is: | The first two identifiers you should be familiar with are the {{mIRC|$left}} and {{mIRC|$right}} identifiers which can be used to return the left or right most part of the original string respectably. Their syntax is: | ||
Line 59: | Line 38: | ||
=== $mid() === | === $mid() === | ||
+ | |||
{{mirc|$left}}() and {{mirc|$right}}() are great but they can get a little complicated if you want to get a substring from the middle of the string. For such cases, the {{mirc|$mid}}() identifier is a more powerful alternative. {{mirc|$mid}}() has the following syntax: | {{mirc|$left}}() and {{mirc|$right}}() are great but they can get a little complicated if you want to get a substring from the middle of the string. For such cases, the {{mirc|$mid}}() identifier is a more powerful alternative. {{mirc|$mid}}() has the following syntax: | ||
Line 74: | Line 54: | ||
== Case Transformation == | == Case Transformation == | ||
+ | |||
The {{mirc|$islower}} and {{mirc|$isupper}} identifiers can be used to determine if a string is entirely made up of uppercase or lowercase letters ({{mIRC|$true}}), or else they return {{mIRC|$false}}. The same functionality is also built into an if statement using the isupper and islower operators. The $upper and $lower identifiers perform case conversion on an entire string or a string character. | The {{mirc|$islower}} and {{mirc|$isupper}} identifiers can be used to determine if a string is entirely made up of uppercase or lowercase letters ({{mIRC|$true}}), or else they return {{mIRC|$false}}. The same functionality is also built into an if statement using the isupper and islower operators. The $upper and $lower identifiers perform case conversion on an entire string or a string character. | ||
Line 92: | Line 73: | ||
=== $lower() and $upper() === | === $lower() and $upper() === | ||
+ | |||
The {{mirc|$lower}}() and {{mirc|$upper}}() identifiers can be used to transform the entire string into uppercase or lowercase letters. For example: | The {{mirc|$lower}}() and {{mirc|$upper}}() identifiers can be used to transform the entire string into uppercase or lowercase letters. For example: | ||
Line 103: | Line 85: | ||
== Searching == | == Searching == | ||
+ | |||
There are a number of identifiers that can be used to search for a substring within a string. The first one is the $pos identifier which has the following syntax: | There are a number of identifiers that can be used to search for a substring within a string. The first one is the $pos identifier which has the following syntax: | ||
Line 127: | Line 110: | ||
=== Replacement === | === Replacement === | ||
− | |||
− | |||
− | |||
− | The syntax for both of them is: | + | There are two built-in string replacement identifiers, {{mirc|$replace}} and {{mirc|$replacex}}. The major difference between the two is that the later one will not apply replacement to any of the replaced strings. The syntax for both of them is: |
<syntaxhighlight lang="mIRC">$replace(<string>, <substring>, <replacement>[, <substring2>, <replacement2>, ...]) | <syntaxhighlight lang="mIRC">$replace(<string>, <substring>, <replacement>[, <substring2>, <replacement2>, ...]) | ||
Line 154: | Line 134: | ||
<pre>5 5 5 5 | <pre>5 5 5 5 | ||
2 3 4 5</pre> | 2 3 4 5</pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
'''Note:''' {{mirc|$replacecs}}/{{mirc|$replacexcs}} are case-sensitive versions of {{mirc|$replace}}/{{mirc|$replacex}}; it has the same syntax. | '''Note:''' {{mirc|$replacecs}}/{{mirc|$replacexcs}} are case-sensitive versions of {{mirc|$replace}}/{{mirc|$replacex}}; it has the same syntax. | ||
=== Substring Removal === | === Substring Removal === | ||
+ | |||
$remove is an identifier that can remove all occurrences of the substrings from the string. The syntax is: | $remove is an identifier that can remove all occurrences of the substrings from the string. The syntax is: | ||
Line 184: | Line 156: | ||
=== $str() === | === $str() === | ||
+ | |||
$str returns the same exact string repeated N amount of times. The syntax is: | $str returns the same exact string repeated N amount of times. The syntax is: | ||
Line 197: | Line 170: | ||
=== $strip() === | === $strip() === | ||
+ | |||
The $strip identifier can remove control codes from a string. The syntax for it is: | The $strip identifier can remove control codes from a string. The syntax for it is: | ||
Line 211: | Line 185: | ||
* m = use messages option settings | * m = use messages option settings | ||
− | + | [[Category:mIRC]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | [[Category:mIRC |