Forum Discussion
4 Replies
- nmrao
Champion Level 1
Is that a partial html? it would be difficult. Full response would help.- henil_shahContributor
The response is in full HTML having a script tag. I tried this
def splitString = myString.split(':')
but getting 'x' now how to extract x out of ' ' ? I used split(' \' ') but its now working. Anyone knows how to split with single quote?
PS - (' \ ' ') is without space! I just kept space here to demonstrate properly
- HKosova
Alumni
How about using a regular expression?
import java.util.regex.* def str = "<script> s2pServerUrl = {uuid : x baseWebUrl : 'x', clientId: '123' </script>" def matcher = str =~ /clientId\s*:\s*['"](\w+)['"]/ def value = matcher[0][1] // matcher[0] is entire matched string, [1] is the captured group log.info value // 123