[SOLVED] How do I simplify return value using Regex?

0 favourites
  • 9 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hello, I've used Imgur API and it worked, the problem is it returns data with all parameters, it looks like:

    I need to know how to use Regex to convert it into simple Link URL and forget every parameters.
    Parameter of URL is "link":"http:\/\/i.imgur.com\/TjJuJ29.jpg"
  • I noticed it's JSON, it's not possible with Regex.

    Isn't there a way to use parse to get a link?

  • you could load that json string into an array and just call the value of the url.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The data is what matters, you could try to isolate it, then get rid of the { }, then a good use a loops and tokens could make it so you put each data as key and values of dictionnary, then you could just retrieve the value you want

  • It's irrelevant that it's JSON. RegEx parses text. You have text.

  • Ubivis , Aphrodite I'm sorry, I'm not expert about backend, I had no clue how to get each JSON property in array or dicctionary, would you explain me how to do it?

    blackhornet Can you help me?

  • You'll need some error code, but this works:


    Key = "link":"(http:.*)"}

    RegexMathAt(JSON, Key, 1)

  • blackhornet I got another workaround, I used this plugin to inspect this JSON and I made ugly hack to get rid of other parameters and got proper return as URL.

    Your snippet is saved on my disk for future reference, thank you!

  • You could try parsing the json with the browser object. For example,

    System set some_variable to

    Browser.ExecJS("(function(){var obj = {""url"":""some_link"", ""other"":""something_else""} return obj.url})();")

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)