-8

如何从以下数据中提取 javascript 中的 url?你能帮我写代码吗?

[
Image{url:'/images/HH/Images/US/NYC/NYC-MEL-1.jpg', description='Exterior', 
          alt='null', sortOrder=1, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-9.jpg', description='Exterior', 
          alt='null', sortOrder=1, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-11.jpg', description='Lobby', 
          alt='null', sortOrder=4, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-5.jpg', description='Guest Room', 
          alt='null', sortOrder=34, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-6.jpg', description='Guest Room', 
          alt='null', sortOrder=34, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-7.jpg', description='Guest Room', 
          alt='null', sortOrder=34, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-8.jpg', description='Guest Room', 
          alt='null', sortOrder=34, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-10.jpg', description='Guest Room', 
          alt='null', sortOrder=34, externalUrl='null'},
Image{url='/images/HH/Images/US/NYC/NYC-MEL-3.jpg', description='Guest Room', 
          alt='null', sortOrder=34, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-2.jpg', description='Guest Room', 
          alt='null', sortOrder=34, externalUrl='null'}, 
Image{url='/images/HH/Images/US/NYC/NYC-MEL-4.jpg', description='Guest Room', 
          alt='null', sortOrder=34, externalUrl='null'}
]
4

1 回答 1

2

好的,我只是给你一个简单的想法,但没有代码:使用“拆分”方法,即:

var myStr = "Hello, I'm here!"; 
var splitedString = myStr.split(", ");

结果splitedString是这样的数组["Hello","I'm here!"]

祝你好运!

于 2012-12-13T10:00:21.617 回答