我正在寻找一个正则表达式来找到一些包含一些字母的单词.我有这个词start,并且通过正则表达式它应该找到包含(s,两个t,a,r)的单词,其中包含至少3个字母.因此,它应该返回所有这些词:
start,tarts,arts,art.所以它至少应该是三个字母,并且只包含那些字符(s,两个t,a,r).
我试过这样的事情:
/(([^s]*s){1})(([^t]*t){2})(([^a]*a){1})([^r]*r){1}/g
Run Code Online (Sandbox Code Playgroud)
但是这个正则表达式不起作用,因为它需要按此顺序排列.
我也试过这个:
[star]{3,}
Run Code Online (Sandbox Code Playgroud)
但它匹配内部的任意数量的字符[],前匹配sss
我想知道如何在 Razor Pages (Page.cshtml) 中获取路由值。前任。
https://localhost:44320/AdminPanel/Admins
如果我使用 MVC,我会将这些数据作为
var controller = ViewContext.RouteData.Values["Controller"]; //AdminPanel
var action = ViewContext.RouteData.Values["Action"]; //Admins
Run Code Online (Sandbox Code Playgroud)
如何在 Razor Pages 中获取这些值?
对于任何试图获得它的人,您可以通过以下方式获得它:
var fullRoute = ViewContext.RouteData.Values["Page"]; // AdminPanel/Admin
Run Code Online (Sandbox Code Playgroud) asp.net-routing razor asp.net-core asp.net-core-2.0 razor-pages
我想从我创建的API(也位于.Net Core中)启动.net Core应用程序。
我UseUrls()在Program.cs文件中添加了功能,因此它将使用我希望它使用的端口。因此,这里看起来是我在其他模块中的Program.cs。
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://*:50003")
.UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = null;
}
)
.UseDefaultServiceProvider(options =>
options.ValidateScopes = false)
.Build();
}
Run Code Online (Sandbox Code Playgroud)
因此,当我打开CMD并在其中键入此模块所在的位置时,dotnet run它将在上运行应用程序http://localhost:50003,这很好,因为那是我要启动的端口。
但是我需要做的是从该API启动此应用程序。这是我编写命令的代码dotnet run:
public IActionResult RunPackage(int id)
{
try
{
var workingDirectory = 'here goes the path of the directory of this module that i want to start running';
var processStartInfo …Run Code Online (Sandbox Code Playgroud) 我正在尝试在React Hooks项目上实现Redux,但它似乎没有很好的工作。我在这里做错什么了吗?
reducer.js
const initialState = {
educations: []
};
export default function home(state = initialState, action){
switch(action.type){
case GET_EDUCATIONS: {
state.educations = action.payload;
return state;
}
default:
return state;
}
}
Run Code Online (Sandbox Code Playgroud)
action.js
import * as types from '../constans/home';
export const getEducations = () => {
return dispatch => {
const edus = [
{value: 1, name: 'Bachelor'},
{value: 2, name: "Master"}
]
dispatch({
type: types.GET_EDUCATIONS,
payload: edus
})
}
}
Run Code Online (Sandbox Code Playgroud)
零件
import React, {useEffect} from 'react';
import {connect} from …Run Code Online (Sandbox Code Playgroud) 我在C#中有一些类,希望在管道中使用它们,我看过有关它的文章,但我还没有做到。
这是我现在使用的方式:
$suite = [MyProject.SuiteBuilder]::CreateSuite('my house')
$houseSet = $suite.AddSet('doors', 'These represents doors')
$houseSet.AddOption('blue', 'kitchen')
$houseSet.AddOption('black', 'bedreoom')
$houseSet.AddOption('white', 'toilet')
Run Code Online (Sandbox Code Playgroud)
我希望能够在管道中像这样使用它:
$suite = [MyProject.SuiteBuilder]::CreateSuite('my house')
$suite | AddSet('doors', 'These represents doors') `
| AddOption('blue', 'kitchen') `
| AddOption('black', 'bedreoom') `
| AddOption('white', 'toilet')
Run Code Online (Sandbox Code Playgroud)
这是我的C#类:
//SuiteBuilder.cs
public static class SuiteBuilder
{
public static Suite CreateTestSuite(string name)
{
return new Suite(name);
}
}
//Suite.cs
public class Suite : PSCmdlet
{
public string Name { get; set; }
public IEnumerable<Set> Sets { get; set; } …Run Code Online (Sandbox Code Playgroud) asp.net-routing asp.net-mvc-routing asp.net-core-mvc asp.net-core-2.0
我试图从Linux中的环境变量中获取connectionString,但问题是它返回null。
当我输入printenv connectionStringtermial 时,它返回变量,但在我编写的应用程序中,System.Environment.GetEnvironmentVariable("connectionString")它返回 null。
有谁知道为什么会发生这种情况?
ps 我正在 Docker 中运行应用程序。
linux environment-variables asp.net-web-api docker .net-core
我有一个哈希表数组,我需要查找是否有元素具有相同的哈希表Name。
我有此HasDuplicate函数返回True或False数组是否包含重复项。
我在这里所做的是,我遍历每个元素,并将Name其添加到另一个数组,然后检查它是否为exists。但是这段代码看起来并不好,我在想是否还有另一种方法可以实现这一目标
# object looks like this
$array = @(
@{ Name = 'First', Passed = $True }
@{ Name = 'First', Passed = $False }
)
Function HasDuplicate
{
param($array)
$all = @()
foreach($item in $array)
{
$item_name = $item.Name
if($all -contains $item_name)
{
Write-Error "Duplicate name ""$item_name"""
return $True
}
else
{
$all += $item_name
}
}
return $False
}
Run Code Online (Sandbox Code Playgroud) asp.net-core ×2
c# ×2
powershell ×2
.net ×1
.net-core ×1
asp.net ×1
docker ×1
javascript ×1
linux ×1
process ×1
razor ×1
razor-pages ×1
react-redux ×1
reactjs ×1
redux ×1
regex ×1
state ×1