-3

How can detect url's from this string. Urls are in quotes that cause problem with multiple items.

"{"output":["www.google.com"],"screenshots":["http://10.200.200.14:5000/screenshots/id=215585/1.png","http://10.200.200.14:5000/screenshots/id=215585/2.png"]}"

I need to extract below:

http://10.244.224.44:5000/screenshots/id=215585/1.png
http://10.244.224.44:5000/screenshots/id=215585/2.png

Edit: I edited the line, it is actually a string and I need to extract urls to make them clickable in ace editor. So Ace editor wants me to specify a regex pattern.

 const CustomHighlightRules = function CustomHighlightRules() {
      let rules = new HighlightRules().getRules();
      for (const rule in rules) {
        rules[rule].unshift({
          token: ['clickables'],
          regex: /(((https?:\/\/)|(www\.))[^\s]+)/,
        });
erondem
  • 140
  • 1
  • 2
  • 18
  • 1
    Apparently you don't know where to start with your regex. Please check out [Reference - What does this regex mean resource](https://stackoverflow.com/questions/22937618), and [Learning Regular Expressions](https://stackoverflow.com/questions/4736) for more info on regex. – Christian Baumann Oct 02 '20 at 07:51
  • `JSON.parse(your_string).screenshots` – Wiktor Stribiżew Oct 02 '20 at 07:53
  • I need this regex to customize ace editor styling, JSON.parse is not way I look for – erondem Oct 02 '20 at 07:59

1 Answers1

-1

Actually you don't need Regex here:

var objJSON = JSON.parse('{"output":["www.google.com"],"screenshots":["http://10.200.200.14:5000/screenshots/id=215585/1.png","http://10.200.200.14:5000/screenshots/id=215585/2.png"]}');

Will parse the Json in obj and then:

document.write(obj.screenshots);

Use obj.screenshots

programmer365
  • 12,641
  • 3
  • 7
  • 28