v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Difference between revisions of "Template:Str/count/doc"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
(Created page with "Essentially {{tl|str/len}}, but counts the number of times {{{<nowiki/>1}}} appears in {{{<nowiki/>2}}}. Note that {{{<nowiki/>1}}} can be any Wikipedia:regular expression.")
 
(Examples)
Line 2: Line 2:
  
 
Note that {{{<nowiki/>1}}} can be any [[Wikipedia:regular expression|regular expression]].
 
Note that {{{<nowiki/>1}}} can be any [[Wikipedia:regular expression|regular expression]].
 +
 +
==Examples==
 +
<pre>{{str/count|a|abca}}</pre>
 +
&rarr; {{str/count|a|abca}}
 +
 +
<pre>{{str/count|\d|abc 123}}</pre>
 +
&rarr; {{str/count|\d|abc 123}}
 +
 +
<pre>{{str/count|\D|abc 123}}</pre>
 +
&rarr; {{str/count|\D|abc 123}}
 +
 +
<pre>{{str/count|\w+|this is an example}}</pre>
 +
&rarr; {{str/count|\w+|this is an example}} (<code>\w+</code> matches one or more "word" characters, but not spaces)

Revision as of 00:47, 25 June 2013

Essentially {{str/len}}, but counts the number of times {{{1}}} appears in {{{2}}}.

Note that {{{1}}} can be any regular expression.

Examples

{{str/count|a|abca}}

→ 2

{{str/count|\d|abc 123}}

→ 3

{{str/count|\D|abc 123}}

→ 4

{{str/count|\w+|this is an example}}

→ 4 (\w+ matches one or more "word" characters, but not spaces)