Forum Discussion
henil_shah
9 years agoContributor
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
9 years agoHow 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- henil_shah9 years agoContributor
Hi All,
I was able to split using substring and split and it finally worked.