小编chi*_*ngc的帖子

在Powershell中使用Regex来抓取电子邮件

我编写了一个脚本来抓取HTML文件中的不同字段,并使用结果填充变量.我正在使用正则表达式来抓取电子邮件.以下是一些示例代码:

$txt='<p class=FillText><a name="InternetMail_P3"></a>First.Last@company-name.com</p>'

$re='.*?'+'([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})'

if ($txt -match $re)
{
    $email1=$matches[1]
    write-host "$email1"
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Bad argument to operator '-match': parsing ".*?([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\
.)+[a-zA-Z]{2,7})([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})" - [x-y] range in reverse order..
At line:7 char:16
+ if ($txt -match <<<<  $re)
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadOperatorArgument
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么?此外,是否有更好的电子邮件正则表达式?

提前致谢.

regex email powershell

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

NP-Complete VS NP-Hard

我试图理解NP-Complete和NP-Hard之间的区别.

以下是我的理解

NP-Hard问题是在多项式时间内无法解决的问题,但可以在多项式时间内验证.
NP-Complete问题是NP中的问题,也是NP-Hard问题.

以上定义是否正确?如果是这样,那么问题不是NP而是NP-Hard.难道它们不会比NP完全问题更难,说它们只能在指数时间内得到解决和验证吗?

algorithm computer-science np-complete np-hard np

4
推荐指数
2
解决办法
6838
查看次数

如何使用正则表达式执行proxypassreverse

这几天我遇到了这个问题,我正在使用Apache服务器的反向代理,我设法通过在配置文件中进行以下更改来运行反向代理:

ProxyPass: /server-01/ server-01.{My server}
ProxyPassReverse: /server-01/ server-01.{My server}

ProxyPass: /server-02/ server-02.{My server}
ProxyPassReverse: /server-02/ server-02.{My server}

ProxyPass: /server-03/ server-03.{My server}
ProxyPassReverse: /server-03/ server-03.{My server}

ProxyPass: /server-04/ server-04.{My server}
ProxyPassReverse: /server-04/ server-04.{My server}
Run Code Online (Sandbox Code Playgroud)

所有这一切都有效,但我想让它变得动态,这样我就不必添加新代码并在添加新代理服务器时重新启动Apache!

regex apache reverse-proxy

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

Android Studio:在项目根目录之外添加库

我有两个项目A和B,并希望通过一个库项目C共享它们之间的一些代码。这样做的正确方法是:

  1. A和B和C都在单独的项目中。(完全不在同一目录中)
  2. 对C的更改将自动在A或B中使用,而无需重新导入C。

我是Android Studio的新手,在这里遇到了各种各样的问题。我真的只想使用位于项目根目录之外的源代码。谢谢!

java android libraries android-studio

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

GoogleApiClient可以在片段中使用,还是必须始终在活动中使用?

GoogleApiClient可以在片段中使用,还是必须始终在Activity中使用

mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
2
解决办法
7378
查看次数

`npm start`问题:ERROR手表EMFILE虽然打开文件限制= 65536

ulimit -a 日志:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited
Run Code Online (Sandbox Code Playgroud)

虽然我仍然在收到EMFILE错误npm start.

react-native@0.3.11 start/node_modules/react-native ./packager/packager.sh

 ===============================================================
 |  Running packager on port 8081.       
 |  Keep this packager …
Run Code Online (Sandbox Code Playgroud)

node.js npm osx-yosemite react-native

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

为什么"1.0"在JavaScript中不等于"+1.0"?

我在JavaScript中做了一个简单的比较,但它不起作用.这是脚本

var value = '1.0';
var minLimit = '+0.5';
var maxLimit = '+999';
if (value >= minLimit && value <= maxLimit) {
    console.log(value);
}
else
{
 console.log('not matched');
}
Run Code Online (Sandbox Code Playgroud)

我有什么遗漏比较吗?这是小提琴http://jsfiddle.net/9ouwkyyt/

javascript

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

检索项目的父项时出错:找不到与给定名称"Theme.Base.AppCompat.DialogWhenLarge.Base"匹配的资源

[2014-11-22 07:46:34 - aa] D:\EclipseAndroidWorkspace\Leaning_exercise\appcompat_v7\res\values-large-v14\themes_base.xml:19: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Base.AppCompat.DialogWhenLarge.Base'.
[2014-11-22 07:46:34 - aa] D:\EclipseAndroidWorkspace\Leaning_exercise\appcompat_v7\res\values-large-v14\themes_base.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Base.AppCompat.Light.DialogWhenLarge.Base'.
[2014-11-22 08:04:40 - aaa] D:\EclipseAndroidWorkspace\Leaning_exercise\appcompat_v7\res\values-large-v14\themes_base.xml:19: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Base.AppCompat.DialogWhenLarge.Base'.
[2014-11-22 08:04:40 - aaa] 
[2014-11-22 08:04:40 - aaa] D:\EclipseAndroidWorkspace\Leaning_exercise\appcompat_v7\res\values-large-v14\themes_base.xml:22: error: Error retrieving parent for item: No resource found that matches …
Run Code Online (Sandbox Code Playgroud)

android

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

在 gitignore 中包含特定的文件扩展名

我想包含 Assets 目录和所有子目录中的所有 *.meta 文件,同时排除 Assets 中的其他所有内容

我试过

/Assets/*
!/Assets/**/*.meta
!*.meta
Run Code Online (Sandbox Code Playgroud)

但只包括 /Assets 中的 *.meta ???

谢谢你的帮助

git gitignore

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

C++哈希弃用警告

我对C++和编程非常陌生,目前正在使用Bjarne Stroustrup的编程:使用C++的原理和实践.我一直收到以下错误

严重性代码说明项目文件行错误C2338已弃用,将被删除.请用 .您可以定义_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS以确认您已收到此警告.

我理解头文件std_lib_facilities.h使用某种不推荐使用的函数,但有没有办法绕过这个?看起来它要我定义"_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS",但我不确定如何做到这一点.任何帮助,将不胜感激!!

c++ deprecated deprecation-warning

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