小编Kau*_*nki的帖子

正则表达式 - HTML代码中的匹配属性

使用正则表达式匹配html属性(在各种html标签中)遇到问题.为此,我使用模式:

myAttr=\"([^']*)\"
Run Code Online (Sandbox Code Playgroud)

HTML片段:

<img alt="" src="1-p2.jpg" myAttr="http://example.com" class="alignleft" />
Run Code Online (Sandbox Code Playgroud)

它从myAttr最后选择文本,/>但我需要选择myAttr="..."(" http://example.com ")

html regex

14
推荐指数
2
解决办法
2万
查看次数

如何从ms sql中的字符串的开始和结束中删除特定字符串中的\n(字符(10))

我有一栏供评论,我需要在一份报告中显示.这里发生了一些时间,用户使用多个进入评论框.我无法访问我只需要在SQL中管理这个东西的代码部分.

所以我删除了不需要的

1 /r/n 
2 /n/n
Run Code Online (Sandbox Code Playgroud)

从使用

REPLACE(REPLACE(Desc, CHAR(13)+CHAR(10), CHAR(10)),CHAR(10)+CHAR(10), CHAR(10)) as Desc,
Run Code Online (Sandbox Code Playgroud)

现在我想删除任何\r\n开始或结束,如果任何字符串

sql-server sql-server-2008

7
推荐指数
1
解决办法
2万
查看次数

如何从字符串中确定日期格式?

今天已经问过这个问题,但所有者似乎已将其删除(即使它有 4 个投票)。但是这个问题很有趣,我决定再次自己发帖。

我在 Javascript 中有一个对象,它有一个带有日期字符串的属性。

现在我想为该属性设置一个新的日期时间,但是如何在不知道其格式的情况下设置新数据?

示例日期时间看起来像这样“2018-01-01T20:09:00”

这个问题可以分为2个答案。

  1. 识别当前提到的格式并将相同的格式设置为对象属性。(如果有人说这是什么类型的日期时间格式,这似乎很容易实现)

  2. 确定一些确定任何日期时间格式并将给定日期时间转换为设置对象属性的通用解决方案。

javascript datetime

7
推荐指数
1
解决办法
9520
查看次数

有没有办法关闭Hangfire与serilog的日志记录?

有没有办法关闭Hangfire与serilog的日志记录?我们正在使用自己的抽象,我不希望所有这些额外的噪音来自Hangfire记录器,同时使用serilog.

// INIT call under web project 
namespace MYApp.Web.App_Start
{
    public static class Bootstrapper
    {
        public static void Run()
        {
            Core.Logging.Serilog.SetConfiguration();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

//设置config方法的项目

namespace MYApp.Core.Logging
{
 public static class Serilog
    {
      public static void SetConfiguration()
            {

                Log.Logger = new LoggerConfiguration()
                    //.WriteTo.File(@"c:\log-.txt", rollingInterval: RollingInterval.Minute, shared: true)
                    .WriteTo.Email(new EmailConnectionInfo()
                    {
                        FromEmail = "xxxxxx@gmail.com",
                        MailServer = "smtp.gmail.com",
                        ToEmail = "xxxx@xxxx.xx.xx",
                        NetworkCredentials = new NetworkCredential("xxxx@gmail.com", "xxxxxxxxx"),
                        Port = 587,
                        EnableSsl = true,
                        EmailSubject = "YYYYYY: Error Log"
                    }, outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {NewLine} …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc serilog hangfire

5
推荐指数
2
解决办法
885
查看次数

有没有办法在 ng-select 上搜索时提供自定义排序?

我遇到的情况是,我需要在 ng-select 下搜索时根据自定义逻辑对数据进行排序。可以选择使用 [searchFn] 跨多个字段进行搜索,但我需要根据我的自定义逻辑对匹配结果进行排序。

  1. 这可能吗 ?
  2. 请分享一些最初的理想如何实现?

ng-select:https://github.com/ng-select/ng-select

angular-ngselect angular

5
推荐指数
1
解决办法
2516
查看次数

这个JavaScript代码有什么区别吗?

我已经看到了以下两种方式实现的各种代码.我总是使用第二个(2.).我想在这里知道两件事.

  1. 这两个代码有什么区别吗?

  2. 哪一个是最佳实践(以及为什么)?

1.

(function () {
    //some code here, angular code
})();
Run Code Online (Sandbox Code Playgroud)

2.

 (function () {
     //some code here, angular code
 });
Run Code Online (Sandbox Code Playgroud)

我还想在这方面建议一些好的博客或书籍,因为我想更详细地学习.谢谢大家提前..

javascript angularjs

4
推荐指数
1
解决办法
130
查看次数

如何修复角度中的引导错误?出了什么问题

我不确定为什么会出现以下错误。

ERROR in node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,34): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/accordion/accordion.d.ts(118,40): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(27,44): error TS1144: '{' or ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(28,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(29,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(30,5): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(31,1): error TS1128: Declaration or statement expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,20): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,21): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,37): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(13,74): error TS1005: '(' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,24): error TS1005: ';' expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,25): error TS1003: Identifier expected.
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker.d.ts(14,41): error …
Run Code Online (Sandbox Code Playgroud)

angular

4
推荐指数
1
解决办法
6630
查看次数

通过使用Iqueryable对数据表进行排序

我有以下函数为jquery数据表网格准备数据.现在我面临除字符串以外的数据类型的跟随错误

无法将类型"System.DateTime"强制转换为"System.Object"类型.LINQ to Entities仅支持转换EDM原语或枚举类型.

码:

public GeneralResponse<IEnumerable<Holiday>> GetHolidays(string filter, 
                int initialPage, 
                int pageSize, 
                out int totalRecords, 
                out int recordFilterd,
                int sortColumn, 
                string sortDirection)
            {
                var response = new GeneralResponse<IEnumerable<Holiday>>();
                totalRecords = 0;
                recordFilterd = 0;
                filter = filter.Trim().ToLower();
                try
                {
                    Expression<Func<Holiday, dynamic>> expr;
                    switch (sortColumn)
                    {
                        case 0:
                            expr = p => p.HolidayDate;
                            break;
                        case 1:
                            expr = p => p.Name;
                            break;
                        case 2:
                            expr = p => p.ExchangeMarket.Name;
                            break;
                        default:
                            expr = p => p.CreatedOn;
                            break;
                    }
                    var data …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework

3
推荐指数
1
解决办法
255
查看次数

如何在不中断的情况下突出显示 html 内容字符串中的搜索文本

我正在寻找一些解决方案,帮助从带有突出显示功能的 html 字符串中搜索术语。我可以通过从字符串中删除 html 内容来做到这一点。但问题是我将无法看到它突出显示的原始内容。我确实有以下功能,可以在没有 html 标记的情况下搜索和突出显示字符串。

private static updateFilterHTMLValue(value: string, filterText: string): string
{
    if (value == null) {
        return value;
    }

    let filterIndex: number = value.toLowerCase().indexOf(filterText);
    if (filterIndex < 0) {
        return null;
    } 
    return value.substr(0, filterIndex) 
        + "<span class='search-highlight'>" 
        + value.substr(filterIndex, filterText.length) 
        + "</span>" 
        +   value.substr(filterIndex + filterText.length, value.length - (filterIndex + filterText.length));
}
Run Code Online (Sandbox Code Playgroud)

因此,为了管理使用 html 对字符串的搜索,我创建了可以使用 html 搜索字符串的新函数。(我在搜索正确的字符串匹配之前删除了 html 部分)

private static test(value: string, filterText: string): string {
    if (value == null) {
        return value;
    } …
Run Code Online (Sandbox Code Playgroud)

html javascript typescript

3
推荐指数
1
解决办法
5631
查看次数

为什么javascript parseInt忽略字符串中的前导零?

我正在尝试将字符串转换为数字,即"09"

parseInt('09') //returns 9 always
Run Code Online (Sandbox Code Playgroud)

获得前导零的数字的最佳方法是什么?如果有人解释,为什么设计的parseInt以不关心前导零的方式会更好.

javascript

1
推荐指数
1
解决办法
5715
查看次数