public function validate
var TemplateRow = (function() {
var $container;
var $containerImages;
var $containerSongs;
var $containerText;
this.create = function() {
$container = $("<div/>").addClass("single");
$containerText = $("<div/>").addClass("text");
$containerImages = $("<div/>").addClass("image");
$containerSongs = $("<div/>").addClass("doc");
$container.append($containerImages)
.append($containerText)
.append($containerSongs);
return this;
};
this.setTextAsHtml = function(value) {
$containerText.html(value);
return this;
};
this.addImage = function(url, title, alt) {
var $block = $("<div/>").addClass("postimage");
var $image = $("<img/>")
.attr("src", url)
.attr("title", title)
.attr("alt", alt);
$block.html($image);
$containerImages.append($block);
return this;
};
this.addSong = function(id, name) {
var $block = $("<div/>").addClass("song");
var $blockId = $("<div/>").addClass("numsong").text(id);
var $blockName = $("<div/>").addClass("namesong").text(name);
$block.append($blockId).append($blockName);
$containerSongs.append($block);
return this;
};
this.getContainer = function() {
return $container;
};
return this;
});
$.each(data, function(index, element) {
var container = new TemplateRow;
container.create().setTextAsHtml(element.text);
$.each(element.image, function(imageIndex, imageUrl) {
container.addImage(imageUrl, "", "");
});
$.each(element.song, function(songIndex, song) {
container.addSong(song.id, song.name);
});
container.getContainer().appendTo("#articles #innerarticles");
});
Чтобы автоматически подрубалось всё что нужноА что нужно?
var urls = new List<string>() {"https://mysite1.com/", "https://mysite2.com/",
"https://mysite3.com/", "https://mysite4.com/",
"https://mysite1.com/test", "https://mysite2.com/test",
"https://mysite5.com/", "https://mysite5.com/234234/23434/sdfas"};
List<String> uris = urls.Select(x => new Uri(x).GetLeftPart(UriPartial.Authority)).Distinct().ToList();
uris.ForEach(x => Console.WriteLine(x));
void Main()
{
var urls = new List<string>();
urls.Add("https://mysite1.com/");
urls.Add("https://mysite2.com/");
urls.Add("https://mysite3.com/");
urls.Add("https://mysite4.com/");
urls.Add("https://mysite1.com/post/168755988566");
urls.Add("https://mysite2.com/post/168755988566");
urls.Add("https://mysite3.com/post/168755988566");
urls.Add("https://mysite4.com/post/168755988566");
var regexPattern = "\\/post\\/\\d*";
var r = new Regex(regexPattern);
var filteredUrls = urls.Select(x => x).Where(x => !r.IsMatch(x));
foreach (var url in filteredUrls)
{
Console.WriteLine(url);
}
}
((https?|ftp):\/\/)?([a-z0-9+!*(),;?&=.-]+(:[a-z0-9+!*(),;?&=.-]+)?@)?([a-z0-9\-\.]*)\.(([a-z]{2,4})|([0-9]{1,3}\.([0-9]{1,3})\.([0-9]{1,3})))(:[0-9]{2,5})?(\/([a-z0-9+%-]\.?)+)*\/?(\?[a-z+&$_.-][a-z0-9;:@&%=+/.-]*)?(#[a-z_.-][a-z0-9+$%_.-]*)?