Did I find the right examples for you? yes no

# conventions.split_super_sub

All Samples(12)  |  Call(6)  |  Derive(0)  |  Import(6)
```Split a symbol name into a name, superscripts and subscripts

The first part of the symbol name is considered to be its actual
'name', followed by super- and subscripts. Each superscript is
preceded with a "^" character or by "__". Each subscript is preceded
by a "_" character.  The three return values are the actual name, a
list with superscripts and a list with subscripts.

>>> from sympy.printing.conventions import split_super_sub
>>> split_super_sub('a_x^1')(more...)
```

```        def split_super_sub(text):
"""Split a symbol name into a name, superscripts and subscripts

The first part of the symbol name is considered to be its actual
'name', followed by super- and subscripts. Each superscript is
preceded with a "^" character or by "__". Each subscript is preceded
by a "_" character.  The three return values are the actual name, a
list with superscripts and a list with subscripts.

>>> from sympy.printing.conventions import split_super_sub
>>> split_super_sub('a_x^1')
('a', ['1'], ['x'])
>>> split_super_sub('var_sub1__sup_sub2')
('var', ['sup'], ['sub1', 'sub2'])

"""
pos = 0
name = None
supers = []
subs = []
while pos < len(text):
start = pos + 1
if text[pos:pos + 2] == "__":
start += 1
pos_hat = text.find("^", start)
if pos_hat < 0:
pos_hat = len(text)
pos_usc = text.find("_", start)
if pos_usc < 0:
pos_usc = len(text)
pos_next = min(pos_hat, pos_usc)
part = text[pos:pos_next]
pos = pos_next
if name is None:
name = part
elif part.startswith("^"):
supers.append(part[1:])
elif part.startswith("__"):
supers.append(part[2:])
elif part.startswith("_"):
subs.append(part[1:])
else:
raise RuntimeError("This should never happen.")

# make a little exception when a name ends with digits, i.e. treat them
# as a subscript too.
m = re.match('(^[a-zA-Z]+)([0-9]+)\$', name)
if m is not None:
name, sub = m.groups()
subs.insert(0, sub)

return name, supers, subs
```

```from .printer import Printer
from .pretty.pretty_symbology import greek_unicode
from .conventions import split_super_sub, requires_partial

```
```                return s

name, supers, subs = split_super_sub(sym.name)
name = translate(name)
supers = [translate(sup) for sup in supers]
```

```## sympy.printing imports
from .printer import Printer
from .conventions import split_super_sub, requires_partial
from .precedence import precedence, PRECEDENCE

```
```    def _deal_with_super_sub(self, string):

name, supers, subs = split_super_sub(string)

name = translate(name)
```

```from .printer import Printer
from .pretty.pretty_symbology import greek_unicode
from .conventions import split_super_sub, requires_partial

```
```                return s

name, supers, subs = split_super_sub(sym.name)
name = translate(name)
supers = [translate(sup) for sup in supers]
```

```## sympy.printing imports
from .printer import Printer
from .conventions import split_super_sub, requires_partial
from .precedence import precedence, PRECEDENCE

```
```    def _print_Symbol(self, expr):
if expr in self._settings['symbol_names']:
return self._settings['symbol_names'][expr]

name, supers, subs = split_super_sub(expr.name)
```

```from sympy.simplify import fraction
from printer import Printer
from conventions import split_super_sub

```
```                return mi

name, supers, subs = split_super_sub(sym.name)
mname = self.dom.createElement('mml:mi')
mname.appendChild(self.dom.createTextNode(name))
```

```from sympy.core import S, C, Basic, Add, Wild, var
from printer import Printer
from conventions import split_super_sub
from sympy.simplify import fraction
from sympy import Interval
```
```    def _print_Symbol(self, expr):
name, supers, subs = split_super_sub(expr.name)

# translate name, supers and subs to tex keywords
greek = set([ 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta',
```