2020-09-05 题目来源:http://www.h-camel.com/index.html
[html] 请写一个正则获取html源码中所有img标签的src地址
/// <summary>
/// 取得HTML中所有图片的 URL。
/// </summary>
/// <param name="sHtmlText">HTML代码</param>
/// <returns>图片的URL列表</returns>
public string[] GetHtmlImageUrlList(string sHtmlText)
{
// 定义正则表达式用来匹配 img 标签
Regex regImg = new Regex(@"<img\b[^<>]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?<imgUrl>[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>", RegexOptions.IgnoreCase);
// 搜索匹配的字符串
MatchCollection matches = regImg.Matches(sHtmlText);
int i = 0;
string[] sUrlList = new string[matches.Count];
// 取得匹配项列表
foreach (Match match in matches)
sUrlList[i++] = match.Groups["imgUrl"].Value;
return sUrlList;
}
转自 https://www.cnblogs.com/liuxiaoji/p/4772343.html
[css] 简写的flex:1的完整写法是什么?
flex 属性用于设置或检索弹性盒模型对象的子元素如何分配空间。
flex 属性是 flex-grow、flex-shrink 和 flex-basis 属性的简写属性。
flex:1; 让所有弹性盒模型对象的子元素都有相同的长度,且忽略它们内部的内容
完整写法 flex: flex-grow flex-shrink flex-basis|auto|initial|inherit;
详见mnd https://developer.mozilla.org/zh-CN/docs/Web/CSS/flex
[js] 获取非行间样式
获取非行间样式
写法1:
let elem1 = document.getElementById("elemId");
let style = window.getComputedStyle(elem1, null);
写法2:
let elem1 = document.getElementById("elemId");
let style = document.defaultView,getComputedStyle(elem1, null);
结合兼容性:
window.getComputedStyle? window.getComputedStyle(element,null)[attr] : element.currentStyle(attr)
数组去重 Array.from(new Set(arr))
数组降维 Array.prototype.concat.apply([], arr);
[软技能] 带团队和提升开发能力的平衡点你是如何把握的?
i am not a leader, i am just a poor programmer