如何获得我需要的部分字符串?
accountid = xxxxxx type = prem servertime = 1256876305 addtime = 1185548735 validuntil = 1265012019 username = noob directstart = 1 protectfiles = 0 rsantihack = 1 plustrafficmode = 1 mirrors = jsconfig = 1 email=noob@live.com lots = 0 fpoints = 6076 ppoints = 149 curfiles = 38 curspace = 3100655714 bodkb = 60000000 premkbleft = 25000000 ppointrate = 116
我希望电子邮件之后的数据=但最高可达live.com.
在Windows中,我想将a解析string为date使用精确格式字符串.
例如,给定字符串
"6/12/2010"
Run Code Online (Sandbox Code Playgroud)
和格式:
"M/d/yyyy"
Run Code Online (Sandbox Code Playgroud)
我想将字符串转换为日期,同时确保日期与格式匹配.
我还需要能够指定Y2K滑动窗口,枢轴.这意味着如果(正确)输入了2位数年份,我将指定将来考虑年份的年数.例如:
Two-digit Year Pivot Four-digit year
============== ===== ===============
30 +0 1929
30 +18 1929
30 +19 1929
30 +20 2029
30 +21 2029
30 +100 2029
Run Code Online (Sandbox Code Playgroud)
.NET已经提供了一个DateTime.ParseExact函数,它几乎完全符合我的需求:
date = DateTime.ParseExact("6/12/2010",
DateTimeFormatInfo.ShortDatePattern,
Thread.CurrentThread.CurrentCulture);
Run Code Online (Sandbox Code Playgroud)
除了我不能告诉它100年的支点价值.
更多例子:
String Format Specifier Date
"6/7/2029" "M/d/yyyy" 6/7/2029
"6/7/29" "M/d/yyyy" (invalid, year too short)
"6/7/29" "M/d/yy" 6/7/1929 (+0 pivot)
"6/7/29" "M/d/yy" 6/7/2029 (+100 pivot
"6/7/29" "M/d/yy" 6/7/2029 (+50 pivot)
"6/7/29" "M/d/yy" 6/7/2029
"6/7/2029" "M.d.yyyy" …Run Code Online (Sandbox Code Playgroud) 我正在使用a DataTable并分配不同类型的列.我有一个场景,我正在接收String数据,我想根据列的指定类型解析它,但我无法弄清楚如何获得解析方法.
是否可以通用方式访问Type实例的解析方法?
如何在javascript上解析此字符串,
var string = "http://www.facebook.com/photo.php?fbid=322916384419110&set=a.265956512115091.68575.100001022542275&type=1";
我只是想在字符串上得到" 265956512115091 ".我以某种方式解析了这个字符串,但仍然不足以得到我想要的东西.
我的代码:
var newstring = string.match(/set=[^ ]+/)[0];
Run Code Online (Sandbox Code Playgroud)
收益:
a.265956512115091.68575.100001022542275&type=1
Run Code Online (Sandbox Code Playgroud) 我有一个javascript聊天机器人,一个人可以在输入框中输入任何他们喜欢的问题,并希望得到准确的答案.我可以做到这一点,但我知道我这一切都错了,因为我不知道这个数字在句子中出现的位置.如果一个人确切输入:
什么是5的平方根这很好用.
如果他输入这样的东西,它就不会.
什么是5的平方根
5的平方根是什么
你知道5的平方根是什么吗?
等等
我需要能够确定句子中出现的数字,然后从那里进行计算.请注意,下面的行是更大的工作聊天机器人的一部分.在下面的行中,我只是试图能够回答任何平方根问题,无论数字出现在句子中的哪个位置.我也知道有一个开放式输入框有许多陷阱,一个人可以输入任何拼写错误等.这只是为了娱乐而不是一个严肃的科学项目.:)
if(
(word[0]=="what's") &&
(word[1]=="the") &&
(word[2]=="square") &&
(word[3]=="root") &&
(word [4]=="of") &&
(input.search(/\d{1,10}/)!=-1) &&
(num_of_words==6)
){
var root= word[5];
if(root<0){
document.result.result.value = "The square root of a negative number is not possible.";
}else{
word[5] = Math.sqrt(root);
word[5] = Math.round(word[5]*100)/100
document.result.result.value = "The square root of "+ root +" is "+ word[5] +".";
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
为了清楚起见,机器人是使用"If statemments"编写的.如果在这种情况下输入不包括单词"what"和"square root"和"some number",那么该行不会触发,并且机器人会通过一般的"我不知道类型响应".所以我希望任何答案都适合我正在使用的格式.善待,我是新来的.我喜欢制作机器人,但我不是一个程序员.谢谢.
目前我们这样做......
let parseDate defaultVal text =
match DateTime.TryParse s with
| true, d -> d
| _ -> defaultVal
Run Code Online (Sandbox Code Playgroud)
是否有可能做到这一点...
let d : DateTime = tryParse DateTime.MinValue "2015.05.01"
Run Code Online (Sandbox Code Playgroud) 说我有以下免费monad:
data ExampleF a
= Foo Int a
| Bar String (Int -> a)
deriving Functor
type Example = Free ExampleF -- this is the free monad want to discuss
Run Code Online (Sandbox Code Playgroud)
我知道如何使用此monad。我可以写一些不错的助手:
foo :: Int -> Example ()
foo i = liftF $ Foo i ()
bar :: String -> Example Int
bar s = liftF $ Bar s id
Run Code Online (Sandbox Code Playgroud)
所以我可以用haskell编写程序,例如:
fooThenBar :: Example Int
fooThenBar =
do
foo 10
bar "nice"
Run Code Online (Sandbox Code Playgroud)
我知道如何打印,解释等。但是如何解析呢?
是否有可能编写一个解析器来解析任意程序,例如:
foo 12
bar nice
foo 11
foo …Run Code Online (Sandbox Code Playgroud) 我尝试解析一个带有日期的字符串,将其转换为日期格式.字符串采用以下格式.
2016年3月30日00:00:00 GMT + 2016年5月30日
但是当我解析字符串我得到一个错误说,
java.text.ParseException:Unparseable date:"Wed Mar 30 00:00:00 GMT + 05:30 2016"(偏移4)
下面是我的代码的一部分.我该如何避免这个错误?任何帮助,将不胜感激.
SimpleDateFormat sdf3 = new SimpleDateFormat("EEE MM dd kk:mm:ss zzzz yyyy",Locale.ENGLISH);
for(int i=0 ; i <jArr.length() ; i++){
String tempDate = jArr.get(i).toString();
dateList.add(tempDate);
}
try{
Date d1 = sdf3.parse(dateList.get(0));
}catch (Exception e){ e.printStackTrace(); }
Run Code Online (Sandbox Code Playgroud) string-parsing ×10
c# ×2
javascript ×2
parsing ×2
string ×2
.net ×1
android ×1
constraints ×1
datetime ×1
delphi ×1
delphi-2007 ×1
f# ×1
free-monad ×1
haskell ×1
inline ×1
java ×1
math ×1
monads ×1
nlp ×1
square-root ×1
text-parsing ×1
types ×1
windows ×1