sqlcurious
asked on
need help with extracting google+ term from the string
Hi Experts, need help in extracting google+ from the following string whenever I have this "providerName";s:7:"Google +";s:10:"
DECLARE @response VARCHAR(MAX)
SET @response='a:4:{s:4:"stat" ;s:2:"ok"; s:7:"profi le";O:8:"s tdClass":1 2:{s:12:"p roviderNam e";s:7:"Go ogle+";s:1 0:"identif ier";s:53: "https://www.google.com/profiles/110433849914130156555";s:13:"v erifiedEma il";s:18:" dbsalyer@g mail.com"; s:17:"pref erredUsern ame";s:8:" dbsalyer"; s:11:"disp layName";s :10:"Dan Salyer";s:4:"name";O:8:"st dClass":3: {s:9:"form atted";s:1 0:"Dan Salyer";s:9:"givenName";s: 3:"Dan";s: 10:"family Name";s:6: "Salyer";} s:5:"email ";s:18:"db salyer@gma il.com";s: 3:"url";s: 45:"https://plus.google.com/110433849914130156555";s:5: "photo";s: 99:"https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=400";s:6: "gender";s :4:"male"; s:12:"goog leUserId"; s:21:"1104 3384991413 0156555";s :17:"provi derSpecifi er";s:10:" googleplus ";}s:11:"m erged_poco ";O:8:"std Class":10: {s:2:"id"; s:21:"1104 3384991413 0156555";s :11:"displ ayName";s: 10:"Dan Salyer";s:17:"preferredUse rname";s:8 :"dbsalyer ";s:6:"gen der";s:4:" male";s:10 :"profileU rl";s:45:" https://plus.google.com/110433849914130156555";s:4:"nam e";O:8:"st dClass":3: {s:9:"form atted";s:1 0:"Dan Salyer";s:9:"givenName";s: 3:"Dan";s: 10:"family Name";s:6: "Salyer";} s:6:"email s";a:1:{i: 0;O:8:"std Class":2:{ s:5:"value ";s:18:"db salyer@gma il.com";s: 4:"type";s :7:"accoun t";}}s:15: "languages Spoken";a: 1:{i:0;s:2 :"en";}s:4 :"urls";a: 1:{i:0;O:8 :"stdClass ":2:{s:5:" value";s:4 5:"https://plus.google.com/110433849914130156555";s:4:" type";s:7: "profile"; }}s:6:"pho tos";a:1:{ i:0;O:8:"s tdClass":2 :{s:5:"val ue";s:99:" https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=400";s:4:"typ e";s:5:"ot her";}}}s: 17:"access Credential s";O:8:"st dClass":7: {s:11:"acc essToken"; s:83:"ya29 .cwEkau4rm 8aC0Tu1kIV N5kvmcS8nH wqo1kJlnts FOS6oKZMZM e8Rd_0g-wW QP9amXs1Ae G88JfIcLw" ;s:3:"uid" ;s:21:"110 4338499141 30156555"; s:7:"expir es";i:1431 644921;s:1 2:"refresh Token";s:4 5:"1/SPFF7 AlKHi4NVs8 km62TZTTGe bREYSEPmW4 eC3W_Ipk"; s:6:"scope s";s:13:"e mail,profi le";s:8:"c lientId";s :72:"66972 5107013-vv ps89hat4g4 u7ri9hiqb8 18pks36qcf .apps.goog leusercont ent.com";s :4:"type"; s:6:"oauth 2";}}'
DECLARE @response VARCHAR(MAX)
SET @response='a:4:{s:4:"stat"
Not following your question . . . what are your expected results given that response?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@kyle Abrahams, thanks for the response, every time I pass a string like in the example, result should be 'google+ ' but in that string I need to have "providerName";s:7:"Google +";s:10:"
@zephyr_hex I will try that approach, will update on more questions which I am sure I will have, thanks for the response
@zephyr_hex I will try that approach, will update on more questions which I am sure I will have, thanks for the response
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot Kyle Abrahams what you have mentioned serves the purpose but looks like I misunderstood the requirement, I just came to know that I need to extract anything that it's in the place of google+ For ex:
Below are the scenarios and results:
Result should be 'google+ ' if in the string I have "providerName";s:7:"Google +";s:10:"
Result should be 'yahoo+ ' if in the string I have "providerName";s:7:"yahoo+ ";s:10:"
Result should be 'bing+ ' if in the string I have "providerName";s:7:"bing+" ;s:10:"
pls suggest, thanks
Below are the scenarios and results:
Result should be 'google+ ' if in the string I have "providerName";s:7:"Google
Result should be 'yahoo+ ' if in the string I have "providerName";s:7:"yahoo+
Result should be 'bing+ ' if in the string I have "providerName";s:7:"bing+"
pls suggest, thanks
I suggest you parse the json string as I mentioned above.
ASKER
Thanks for the advice, it worked