我想拆分字符串:"Hello [You] All"
到以下数组:
H,e,l,l,o,[You],A,l,l
我尝试用拆分做到这一点:
my $str = "Hello[You]All";
my @list = split(/(\[.*?\]|.)/, $str);
foreach (@list) {
print "->$_\n";
}
Run Code Online (Sandbox Code Playgroud)
既然我尝试了分裂不应该做的事情,它给了我以下数组:
,H,,e,,l,,l,,o,,[You],,A,,l,,l,
我需要采取的下一步是删除空格.
虽然它不是最好的解决方案,但它是我找到的唯一解决方案,没有任何太混乱.我在这里发帖询问是否有人知道更好的方法来解决这个问题?
我尝试使用jQuery和CodeIgniter使用JSON调用来创建我的第一个AJAX.但由于一些奇怪的原因,它不起作用.
jQuery代码:
var item = "COOL!";
$.post("http://192.168.8.138/index.php/main/test", { "item" : item },
function(data){
alert(data.result);
}, "json");
Run Code Online (Sandbox Code Playgroud)
CodeIgniter代码:
<?php
class main extends Controller {
function test() {
$item = trim($this->input->post('item'));
$array = array('result' => $item);
echo json_encode($array);
}
}
?>
Run Code Online (Sandbox Code Playgroud)
我试图http://192.168.8.138/index.php/main/test手动访问该页面,它似乎正在工作,我得到:{"result":""}
我也尝试用Firebug看,XMLHttpRequest但什么都看不见.
我不知道我做错了什么......非常需要帮助.谢谢.
UNUserNotificationCenterDelegate从后台删除时不起作用。当应用程序停留在前台和后台时,它工作正常。
这是代码
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let rootViewController = self.window!.rootViewController as! UINavigationController
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let profileViewController = mainStoryboard.instantiateViewController(withIdentifier: "SampleViewController") as! SampleViewController
rootViewController.pushViewController(profileViewController, animated: true)
completionHandler()
}
}
Run Code Online (Sandbox Code Playgroud)
当应用程序从后台删除时,不会调用委托方法。请帮帮我
我决定使用jQuery来满足我所有与AJAX相关的客户端需求.但是jQuery对于同一个任务有太多的功能:$ .post,$.get,$ .ajax,$ .getJSON ......我的问题是我应该使用什么?
编辑:我将使用POST和JSON连接到CodeIgniter PHP框架.
谢谢.
我在使用javadoc时遇到了麻烦.它似乎既有用又极其愚蠢!我正在尝试为类编写多行描述:
/**
* this is my class, there are many like it, but this one is mine!
*
* blah blah blah
* - blah blah
* - blah blah
*/
Run Code Online (Sandbox Code Playgroud)
但是当使用该类时,描述显示为单行blob!请告诉我,制作它的人比这更聪明,并且有一种方法可以让javadocs显示多行描述.
谢谢.