Question: This is the HTML I want to extract from.

```
<input type="hidden" id="continueTo" name="continueTo" value="/oauth2/authz/?response_type=code&client_id=localoauth20&redirect_uri=http%3A%2F%2Fbg-sip-activemq%3A8080%2Fjbpm-console%2Foauth20Callback&state=72a37ba7-2033-47f4-8e7e-69a207406dfb" />

```

I need a Xpath to extract only state value i.e `72a37ba7-2033-47f4-8e7e-69a207406dfb`

Answer: 
The XPATH:

```
//input[@id="continueTo"]/@value

```

It will get the value of the node `input` with id `continueTo`. Then it will need to be processed with a Regex first to get a final result.

The Regex:

```
`[^=]+$`

```

`$` means the end of the string. It will get everything on the end of the string which is not `=`.
Use below code:-

```
    String val = driver.findElement(By.xpath("//input[@id='continueTo']/@value")).getText();

    String [] myValue = val.split("&state=");

    System.out.println(myValue[1]);

```

Hope it will help you :)