Question: The html element is below,

```
<div style="width: 80.42%;" class="classA"></div>

```

Using this code I can extract the whole style element:

```
response.xpath("//div[@class='classA']").xpath("@style").extract()

```

But I want get the width value of the style element, that is 80.42%, how can I do?

Answer: 
you could use .re(), like this:

```
response.xpath("//div[@class='classA']").xpath("@style").re('width: (\d+\.\d+%)')

```

it can be work
I would just treat it as a text string and split it as needed:

```
text = '<div style="width: 80.42%;" class="classA"></div>'

if "width:" in text:
    # split at first occurance of "width:" take everything thereafter
    text = text.split("width:",1)[1]
    # split at first semicolon take everything before
    text = text.split(";",1)[0]
    # strip whitespace
    text = " ".join(text.split())

print text

>>>80.42%

```

or using the percent symbol instead of the semicolon:

```
text = '<div style="width: 80.42%;" class="classA"></div>)'

if "width:" in text:
    # split after width
    text = text.split("width:",1)[1]
    # split before percent
    text = text.split("%",1)[0]
    # add back percent
    text += '%'
    # strip whitespace
    text = " ".join(text.split())

print text

>>>80.42%

```

or concisely

```
text = '<div style="width: 80.42%;" class="classA"></div>)'

if "width:" in text: 
    text = " ".join(((text.split("width:",1)[1]).split("%",1)[0]+'%').split())

print text

>>>80.42%

```