To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 6a95b09a authored by vermeul's avatar vermeul
Browse files

Update 12-Regular_Expressions.md

parent f373ca0f
......@@ -102,14 +102,14 @@ regex = re.compile(
The example above can be rewritten by using the traditional `strip()` function to remove leading and trailing spaces, and the `re.split` function to separate attribute and alias:
```
```python
input_string = input_string.strip()
attribute, alias = re.split(r'\s+AS\s+', input_string, flags=re.IGNORECASE)
```
However, if no alias was defined, this will throw the following error:
```
```python
ValueError: not enough values to unpack (expected 2, got 1)
```
......@@ -117,7 +117,7 @@ This is very unfortunate, as we often encounter real-life problems, where a spli
<strong>
```
```python
input_string = input_string.strip()
attribute, *alias = re.split(r'\s+AS\s+', input_string, flags=re.IGNORECASE)
alias = alias[0] if alias else attribute
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment