Browse Source

String

pull/46/head
Jure Šorn 5 years ago
parent
commit
d501423ade
2 changed files with 10 additions and 12 deletions
  1. 13
      README.md
  2. 9
      index.html

13
README.md

@ -325,10 +325,15 @@ String
<str> = <str>.translate(<table>) # Use `str.maketrans(<dict>)` to generate table. <str> = <str>.translate(<table>) # Use `str.maketrans(<dict>)` to generate table.
<list> = textwrap.wrap(<str>, width) # Nicely breaks string into lines. <list> = textwrap.wrap(<str>, width) # Nicely breaks string into lines.
``` ```
```python
<str> = chr(<int>) # Converts int to unicode char.
<int> = ord(<str>) # Converts unicode char to int.
```
* **Also: `'lstrip()'`, `'rstrip()'`.** * **Also: `'lstrip()'`, `'rstrip()'`.**
* **Also: `'lower()'`, `'upper()'`, `'capitalize()'` and `'title()'`.** * **Also: `'lower()'`, `'upper()'`, `'capitalize()'` and `'title()'`.**
### Properties
### Property Methods
```text ```text
+---------------+----------+----------+----------+----------+----------+----------+ +---------------+----------+----------+----------+----------+----------+----------+
| | [\t\n\r] | [ !#$%…] | [A-Za-z] | [¼½¾…] | [¹²³…] | [0-9] | | | [\t\n\r] | [ !#$%…] | [A-Za-z] | [¼½¾…] | [¹²³…] | [0-9] |
@ -341,12 +346,6 @@ String
+---------------+----------+----------+----------+----------+----------+----------+ +---------------+----------+----------+----------+----------+----------+----------+
``` ```
### Char
```python
<str> = chr(<int>) # Converts int to unicode char.
<int> = ord(<str>) # Converts unicode char to int.
```
Regex Regex
----- -----

9
index.html

@ -436,11 +436,14 @@ to_exclusive = &lt;range&gt;.stop
&lt;str&gt; = &lt;str&gt;.translate(&lt;table&gt;) <span class="hljs-comment"># Use `str.maketrans(&lt;dict&gt;)` to generate table.</span> &lt;str&gt; = &lt;str&gt;.translate(&lt;table&gt;) <span class="hljs-comment"># Use `str.maketrans(&lt;dict&gt;)` to generate table.</span>
&lt;list&gt; = textwrap.wrap(&lt;str&gt;, width) <span class="hljs-comment"># Nicely breaks string into lines.</span> &lt;list&gt; = textwrap.wrap(&lt;str&gt;, width) <span class="hljs-comment"># Nicely breaks string into lines.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;str&gt; = chr(&lt;int&gt;) <span class="hljs-comment"># Converts int to unicode char.</span>
&lt;int&gt; = ord(&lt;str&gt;) <span class="hljs-comment"># Converts unicode char to int.</span>
</code></pre>
<ul> <ul>
<li><strong>Also: <code class="python hljs"><span class="hljs-string">'lstrip()'</span></code>, <code class="python hljs"><span class="hljs-string">'rstrip()'</span></code>.</strong></li> <li><strong>Also: <code class="python hljs"><span class="hljs-string">'lstrip()'</span></code>, <code class="python hljs"><span class="hljs-string">'rstrip()'</span></code>.</strong></li>
<li><strong>Also: <code class="python hljs"><span class="hljs-string">'lower()'</span></code>, <code class="python hljs"><span class="hljs-string">'upper()'</span></code>, <code class="python hljs"><span class="hljs-string">'capitalize()'</span></code> and <code class="python hljs"><span class="hljs-string">'title()'</span></code>.</strong></li> <li><strong>Also: <code class="python hljs"><span class="hljs-string">'lower()'</span></code>, <code class="python hljs"><span class="hljs-string">'upper()'</span></code>, <code class="python hljs"><span class="hljs-string">'capitalize()'</span></code> and <code class="python hljs"><span class="hljs-string">'title()'</span></code>.</strong></li>
</ul> </ul>
<div><h3 id="properties">Properties</h3><pre><code class="text language-text">+---------------+----------+----------+----------+----------+----------+----------+
<div><h3 id="propertymethods">Property Methods</h3><pre><code class="text language-text">+---------------+----------+----------+----------+----------+----------+----------+
| | [\t\n\r] | [ !#$%…] | [A-Za-z] | [¼½¾…] | [¹²³…] | [0-9] | | | [\t\n\r] | [ !#$%…] | [A-Za-z] | [¼½¾…] | [¹²³…] | [0-9] |
+---------------+----------+----------+----------+----------+----------+----------+ +---------------+----------+----------+----------+----------+----------+----------+
| isprintable() | | yes | yes | yes | yes | yes | | isprintable() | | yes | yes | yes | yes | yes |
@ -451,10 +454,6 @@ to_exclusive = &lt;range&gt;.stop
+---------------+----------+----------+----------+----------+----------+----------+ +---------------+----------+----------+----------+----------+----------+----------+
</code></pre></div> </code></pre></div>
<div><h3 id="char">Char</h3><pre><code class="python language-python hljs">&lt;str&gt; = chr(&lt;int&gt;) <span class="hljs-comment"># Converts int to unicode char.</span>
&lt;int&gt; = ord(&lt;str&gt;) <span class="hljs-comment"># Converts unicode char to int.</span>
</code></pre></div>
<div><h2 id="regex"><a href="#regex" name="regex">#</a>Regex</h2><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> re <div><h2 id="regex"><a href="#regex" name="regex">#</a>Regex</h2><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> re
&lt;str&gt; = re.sub(&lt;regex&gt;, new, text, count=<span class="hljs-number">0</span>) <span class="hljs-comment"># Substitutes all occurrences.</span> &lt;str&gt; = re.sub(&lt;regex&gt;, new, text, count=<span class="hljs-number">0</span>) <span class="hljs-comment"># Substitutes all occurrences.</span>
&lt;list&gt; = re.findall(&lt;regex&gt;, text) <span class="hljs-comment"># Returns all occurrences.</span> &lt;list&gt; = re.findall(&lt;regex&gt;, text) <span class="hljs-comment"># Returns all occurrences.</span>

Loading…
Cancel
Save