我试图使用Bash'expr index"获取索引位置.
例如
$ echo `expr index "Info.out.2014-02-08:INFO|SID:sXfzRjbmKbwX7jyaW1sog7n|Browser[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0]" Mozilla`
Run Code Online (Sandbox Code Playgroud)
我试图获取单词"Mozilla"的索引位置,然后使用索引值获取子字符串.
我得到的结果是4.是否是Info之后的问题?我该如何解决这个问题?
我按照Advanced Bash脚本指南www.tldp.org/LDP/abs/html/进行了操作.见表B-5.字符串操作
expr index"$ string"$ substring $ substring*中第一个字符的$ string中的数字位置匹配[0如果不匹配,则第一个字符计为位置1]
我尝试过一些简单的东西,但它确实有用.
我在cygwin中运行bash.
$ ./bash --version
GNU bash, version 4.1.10(4)-release (i686-pc-cygwin)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Run Code Online (Sandbox Code Playgroud)
谢谢.
我有一个仅接受货币金额的文本框(例如123.40),并且编写了以下例程以仅允许数字,小数点和退格键。问题是它不允许用户将值(例如Ctrl-V)复制和粘贴到文本框中。
Private Sub unitPriceTxtBox_keypress(ByVal sender As System.Object, ByVal e As KeyPressEventArgs) Handles unitPriceTxtBox.KeyPress
If (Not e.KeyChar = ChrW(Keys.Back) And ("0123456789.-").IndexOf(e.KeyChar) = -1) Or (e.KeyChar = "." And unitPriceTxtBox.Text.ToCharArray().Count(Function(c) c = ".") > 0) Then
e.Handled = True
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
我正在做一些在线研究,而ctrl v键使用的是代码22。请参阅https://social.msdn.microsoft.com/Forums/en-US/5824457e-9112-43ef-83df-7037a36dd365/what-is-the -keychar-for-ctrlc-and-ctrlv-in-c?forum = winforms,但似乎不起作用。
密钥代码的另一个参考在这里。 https://msdn.microsoft.com/zh-CN/library/system.windows.forms.keys(v=vs.110).aspx
有人有见识吗?
谢谢。