我正在寻找C++ 11中的正则表达式,它可以匹配字符串中的子字符串.
类似的东西: "It´s a dark night out there..."我正在寻找ark
因此,如果子字符串位于字符串中的某个位置,则此表达式应匹配.此外,我想可以选择说这个匹配应该区分大小写.
我已经尝试过了,但似乎没有用......
string str = "It´s a dark night out there...";
regex ex ("ark");
if (regex_match (str,ex))
cout << "Match found!";
Run Code Online (Sandbox Code Playgroud)
有人知道这样的事吗?
让我说我有一个URL http://example.com/files/public_files/test.zip,我想提取最后一个子路径,所以test.zip,我怎么能这样做?
我来自Python,所以我还是Java和学习的新手.在Python中你可以这样做:
>>> x = "http://example.com/files/public_files/test.zip"
>>> x.split("/")[-1]
'test.zip'
Run Code Online (Sandbox Code Playgroud) 嗨,我想尝试用javascript设置子字符串.这是我的代码:
function runtest(){
document.getElementById("test1").innerHTML.substring(0,2).style.fontStyle="italic";
}
Run Code Online (Sandbox Code Playgroud)
子字符串函数有效,但是当我添加样式时,错误控制台会给出错误"undefined".如何使用javascript设置此子字符串的样式?
我正在尝试使用子字符串,以便在我的aspx母版页上获取日期的特定部分.我需要这个的原因与我下载的模板和它背后的CSS有关.这是我得到的代码:
<span><%= DateTime.Today.ToString("M").Substring(3), ((int)(DateTime.Today.ToString("M").Length) - 2) %></span>
Run Code Online (Sandbox Code Playgroud)
我需要选择当前月份,以便前3个字符位于第一个跨度中,其余字符位于第二个跨度中.我需要减去2的原因是因为它增加了之后一个月的日期.
预先感谢您的任何帮助.
我需要你对给定问题的帮助
我有一个带有列工人的表,它提供了数据
thorax1 [00400-00479] head1 [00100-00228] lab66 [lab661]
the whole date is in single column
我们有一个页面,我们可以命令删除任何给定的字符串.
为了删除记录,我们只给出方括号中的代码.
例如,如果我们需要删除 head1 [00100 - 00228],我们只给00100 - 00228删除字符串.
这里我的问题是写一个查询,我们可以给00100 - 00228或00400 - 00479删除head1 [00100 - 00228]或thorax1 [00400 - 00479] 记录.
我在这样的PHP中得到一个字符串值 -
How are you|1 I am fine|2 That is fine|3
Run Code Online (Sandbox Code Playgroud)
我想将此字符串分隔符转换为此整数值.基本上我需要这3个值.
How are you|1
I am fine|2
That is fine|3
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议我能做些什么.
如何在javascript中删除字符串中的子字符串(在最后一次斜杠之后)
c:/ Program File/Internet Explorer
至
c:/程序文件/
看看实施情况,但未能想到对此的解释,但也许有人会知道.
public static void main(String[] args) throws Exception {
List<String> emptyStrings = new ArrayList<String>();
List<String> emptySubStrings = new ArrayList<String>();
for (int i = 0; i < 20000; i++) {
String actuallyEmpty = "";
String subStringedEmpty = " ";
subStringedEmpty = subStringedEmpty.substring(0, 0);
emptyStrings.add(actuallyEmpty);
emptySubStrings.add(subStringedEmpty);
}
System.out.println("Substring test");
// Write to files
long time = System.currentTimeMillis();
writeObjectToFile(emptyStrings, "empty.list");
System.out.println("Time taken to write empty list " + (System.currentTimeMillis() - time));
time = System.currentTimeMillis();
writeObjectToFile(emptySubStrings, "substring.list");
System.out.println("Time taken to write substring list " …Run Code Online (Sandbox Code Playgroud) 我有一个字符串FILENAME,实际上在foreach循环中保存文件名.字符串将是这样的:
MyFile_TEST_INDIA_20160728
MyFile_TEST_AMERICA_20160728
MyFile_TEST_GERMANY_20160728
Run Code Online (Sandbox Code Playgroud)
我需要获取国家/地区名称的前2个字符.我试过以下:
String rmtdir = Filename.substring(Filename.length() - 12, Filename.length() - 12);
System.out.println(rmtdir);
Run Code Online (Sandbox Code Playgroud)
但通过使用它,我只能获得INDIA所需的数据.
对于其他国家/地区,我手动需要更新子字符串的第二部分,并考虑到国家/地区的扩展长度.
像美国和德国一样:
String rmtdir = Filename.substring(Filename.length() - 12, Filename.length() - 14);
Run Code Online (Sandbox Code Playgroud)
有没有办法转到起始索引并选择要选择的职位数?
我昨晚花了很多时间调试这段代码.我有两个数据文本文件,都包含18000个字符.我想将这些18000分成两个子串,每个子串100个,这使得180次迭代.
棘手的是,在前180次迭代中,两个子串的大小都很好.在18次迭代之后,子串的大小为0.
两个文件都正确打开.我可以打印它们等等.我尝试以我能想到的所有可能方式分配子字符串,但到目前为止找不到解决方案.
int main(int argc, char const *argv[]) {
//Ive loaded two files into two strings buff1 and buff2 both size of 18000 chars
//It works fine with small data example, I dunno why but eventually I have work with much more bigger data set
//Id like to divide them into 100 char long pieces and do some stuff with that
char *substrA; //substring for buff1
char *substrB; //substring for buff2
substrA = malloc((wlen+1)*sizeof(char)); //word length wlen=100
substrA = …Run Code Online (Sandbox Code Playgroud)