我正在使用http://www.phpliveregex.com/检查我的正则表达式是否正确,它找到了多个匹配的行.
我正在做这个正则表达式:
$lines = explode('\n', $text);
foreach($lines as $line) {
$matches = [];
preg_match("/[0-9]+[A-Z][a-z]+ [A-Z][a-z]+S[0-9]+\-[0-9]+T[0-9]+/uim", $line, $matches);
print_r($matches);
}
Run Code Online (Sandbox Code Playgroud)
在$text它看起来像这样:http://pastebin.com/9UQ5wNRu
问题是打印的匹配只有一个匹配:
Array
(
[0] => 3Bajus StanislavS2415079249-2615T01
)
Run Code Online (Sandbox Code Playgroud)
为什么这样对我?有什么想法可以解决问题吗?
也许你已经注意到文本中没有斯洛伐克语的常规字母字符(来自pastebin).如何匹配这些字符并选择具有以下格式的用户:
{number}{first_name}{space}{last_name}{id_number}
Run Code Online (Sandbox Code Playgroud)
怎么做?
好的第一个问题是固定的.谢谢@ chris85.我应该preg_match_all在整篇文章中使用并做到这一点.现在我得到了一个名字中包含非斯洛伐克(英语)字母的所有学生.
我正在创建一个应用程序,您可以在其中创建流程图(图表).然后我正在分析这个算法,我正在创建一个图表,Chart.js其中x轴是输入的数量/输入的大小,y轴是程序采取的步数.我需要在以下方面绘制以下数学函数Chart.js:
f(x) = x, f(x) = x^2, f(x) = x*log(x).
Run Code Online (Sandbox Code Playgroud)
那些是我需要绘制的算法的复杂性......我正在使用typescript它.可能吗?
我刚刚买了一个覆盆子Pi 3.我试图运行它,但首先它写connection refused了ssh尝试.在我运行raspi-config并启用了ssh后,我现在得到了一个Connection closed by 192.168.0.31.当我扫描该机器上的端口时,它22/tcp是打开的(使用nmap).可能是什么问题呢?
我正在尝试向我的API端点发出GET请求,当我从另一台服务器向API发出请求时,我看到了这个奇怪的错误(在API上):
170125/230803.439, [log,connection,client,error] data: {"bytesParsed":0,"code":"HPE_INVALID_METHOD"}
Run Code Online (Sandbox Code Playgroud)
这个错误是什么意思?
我这样做:
@Override
protected Void doInBackground(String... strings) {
try {
String query = "username=" + strings[0] + "&duration=" + strings[1] + "&distance=" + strings[2];
URL url = new URL(ScoresActivity.URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
Writer writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(query);
writer.flush();
writer.close();
/*conn.addRequestProperty("username", strings[0]);
conn.addRequestProperty("duration", strings[1]);
conn.addRequestProperty("distance", strings[2]);*/
Log.v(TAG, strings[0] + " - " + strings[1] + " - " + strings[2]);
//conn.connect();
} catch(Exception e) {
Log.e(TAG, "exception", e);
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
但请求只是没有在服务器上生效...在服务器上我应该看到发送的数据,但我没有看到它们
我也试过这个:
curl -XPOST --data "username=duri&duration=600&distance=555" …Run Code Online (Sandbox Code Playgroud)