import re


def subword(string, sub):
    """
    Extract number of subwords from sentences and words.

    Parameters
    ----------
        string: str
            Text selected to apply transformation.

        sub: str
            subwords from sentences

    Examples:
    ---------
    ```python
    sentence = 'Fundamentalism and constructivism are important skills'
    subword(sentence,'ism') # change subword and try for others
        >>> 2
    ```
    """
    text = re.findall(sub, string)
    return len(text)