我正在尝试创建一个regex
验证用户名,该用户名应与以下内容匹配:
(._-)
允许一个特殊字符,它不能位于字符串的极值这是针对HTML5验证模式的,遗憾的是它必须是一个很大的正则表达式.
到目前为止,这就是我所拥有的:
^(?=(?![0-9])[A-Za-z0-9]+[._-]?[A-Za-z0-9]+).{3,20}
Run Code Online (Sandbox Code Playgroud)
但积极的前瞻可以重复多次,允许不止一个特殊角色,这不是我想要的.我不知道如何纠正这一点.
Laravel 版本:5.5
PHP版本:7
你好,我想执行这个查询:
select (case
when(title like 'my-keyword') then 1
when(description like 'my-keyword') then 2
) as ordering from products where id > 10;
Run Code Online (Sandbox Code Playgroud)
当我通过查询生成器执行此操作时:
$products = DB::table('products')->select(DB::raw('(case
when(title like "?") then 1
when(description like "?") then 2
) as ordering'))->where('id', '>', 10)->setBindings(['my-keyword', 'my-keyword'])->paginage(10);
Run Code Online (Sandbox Code Playgroud)
这将获得计数,正如我们所知,这将删除所有选择部分并将其替换为 count(*) 作为聚合,因此如果我在此查询生成器上使用 setBindings 并传递 ['my-keyword', 'my-keyword']此聚合查询将更改为:
select count(*) as aggregate from products where id > my-keyword;
Run Code Online (Sandbox Code Playgroud)
因此,这将导致在此查询和其他类似查询的替代方案上使用分页的问题!
为了解决这个问题,我更改了/..../Query/Builder.php中的一些代码:
$total = $this->getCountForPagination($columns);
Run Code Online (Sandbox Code Playgroud)
对此:
$all = $this->get();
$total = $all->count();
Run Code Online (Sandbox Code Playgroud)
对于这种情况,我知道这是错误的,但现在它有效!
我该怎么做才能以正确的方式解决这个问题?
我正在开发一个小的C#WPF应用程序,我想知道xaml中是否有任何等效的html title属性,这样当鼠标悬停在按钮或元素上时,它会显示一个简短的文本,以帮助用户知道什么那个按钮呢?
如果它不存在,那我该如何实现呢?
所以我有一个代码来检测插入该方法的设备
SerialPort.GetPortNames();
Run Code Online (Sandbox Code Playgroud)
无论如何,一切正常,除非我打开现有端口(从列表中选择它)
port = new SerialPort(portname, 9600);
port.Open();
Run Code Online (Sandbox Code Playgroud)
然后,如果设备被拔掉,它不会从列表中删除..我认为这是因为端口没有关闭..
但我无法弄清楚为什么它仍然在列表中如果我不手动关闭它,即使设备已拔下插头..
port.Close();
Run Code Online (Sandbox Code Playgroud)
因为如果我打开一个不在列表中的端口,它就不会出现在列表中.
谁能解释我这种行为?
仅当您位于父块内部时,父块的props.isSelected
才为真,但当您在该块的innerBlocks 内部编辑时则不然。
如何从父块检查用户是否正在编辑该父块的内部块(无论多深)
我这么问是因为我想为父级的内部块执行某种切换功能,直到您选择父级块并尝试使用时才可见,props.isSelected
但显然当您开始编辑内部块时它会立即消失,因为父级不再被选中
这是一个简单的代码,应该可以演示我在说什么
registerBlockType('test/parent', {
name: 'Parent',
edit: (props) => {
const template = [['test/child'],['test/child']];
if (props.isSelected) {
return <InnerBlocks template={template}/>;
}
return <div>Click me to see my inner block</div>;
},
save: (props) => {
return <InnerBlocks.Content />;
}
};
registerBlockType('test/child', {
name: 'Child',
parent: ['test/parent'],
edit: (props) => {
return <div>I'm the child I can have some more nested blocks but if you click on me I will be gone because my parent …
Run Code Online (Sandbox Code Playgroud) 我还在学习wpf并且我正在尝试创建自己的控件但是我将问题注册为dependencyProperty
假设我有我的控件,我希望用户为我的控件的OnChange事件指定一个函数,我试过以下
public readonly static DependencyProperty OnChangeProperty;
public delegate void DependencyPropertyChangedEventHandler(Object sender, DependencyPropertyChangedEventArgs e);
public DependencyPropertyChangedEventHandler Change;
OnChangeProperty = DependencyProperty.Register("OnChange", typeof(DependencyPropertyChangedEventHandler), typeof(MyControl), new FrameworkPropertyMetadata(null));
public DependencyPropertyChangedEventHandler OnChange
{
get { return (DependencyPropertyChangedEventHandler)GetValue(OnChangeProperty); }
set { SetValue(OnChangeProperty, value); }
}
<my:MyControl OnChange="Control_OnChange"/>
Run Code Online (Sandbox Code Playgroud)
但是它没有用,它在遇到"Control_OnChange"时给了我一个XAML解析异常,有人能指出我正确的方向吗?我在MSDN或SO中没有找到任何答案,我错过了什么?