Questions tagged «string»

字符串是有限的符号序列,通常用于文本,尽管有时用于任意数据。

11
逐行读取字符串
给定一个不太长的字符串,逐行读取它的最佳方法是什么? 我知道你可以做: BufferedReader reader = new BufferedReader(new StringReader(<string>)); reader.readLine(); 另一种方法是在eol上获取子字符串: final String eol = System.getProperty("line.separator"); output = output.substring(output.indexOf(eol + 1)); 还有其他更简单的方法吗?我对上述方法没有任何问题,只是想知道你们中是否有人知道一些看起来更简单,更有效的方法?
144 java  string 

27
创建一个包含n个字符的字符串
java中有没有一种方法可以用指定数量的指定字符创建字符串?就我而言,我需要创建一个包含10个空格的字符串。我当前的代码是: StringBuffer outputBuffer = new StringBuffer(length); for (int i = 0; i < length; i++){ outputBuffer.append(" "); } return outputBuffer.toString(); 有没有更好的方法来完成同一件事。特别是我想快速(在执行方面)。

21
VB.NET中的多行字符串
有没有办法像Python一样在VB.NET中具有多行字符串 a = """ multi line string """ 还是PHP? $a = <<<END multi line string END; 当然不是 "multi" & _ "line
144 string  vb.net 

20
如何删除字符串的左侧部分?
我有一些简单的python代码,可在文件中搜索字符串,例如path=c:\path,其中c:\path部分可能会有所不同。当前代码是: def find_path(i_file): lines = open(i_file).readlines() for line in lines: if line.startswith("Path="): return # what to do here in order to get line content after "Path=" ? 取得文字的简单方法是什么Path=?
144 python  string 

7
std :: cin输入带有空格?
#include <string> std::string input; std::cin >> input; 用户想要输入“ Hello World”。但是cin在两个词之间的空格处失败。我如何才能cin吸收全部Hello World? 我实际上是用结构体cin.getline来做的,似乎没有用。这是我的代码: struct cd { std::string CDTitle[50]; std::string Artist[50]; int number_of_songs[50]; }; std::cin.getline(library.number_of_songs[libNumber], 250); 这产生一个错误。有任何想法吗?
144 c++  string  space 

15
删除某个字符后的字符串部分
我只是想知道如何在PHP中某个子字符串之后删除所有内容 例如: Posted On April 6th By Some Dude 我想要它,以便它删除包括子字符串“ By”在内的所有文本。 谢谢
144 php  string 



7
为什么我不能发出字符串?
为什么我不能cout string这样: string text ; text = WordList[i].substr(0,20) ; cout << "String is : " << text << endl ; 当我这样做时,出现以下错误: 错误2错误C2679:二进制'<<':未找到采用'std :: string'类型的右侧操作数的运算符(或没有可接受的转换)c:\ users \ mollasadra \ documents \ visual studio 2008 \ projects \ barnamec \ barnamec \ barnamec.cpp 67 barnamec ** 令人惊讶的是,即使这样也不起作用: string text ; text = …
143 c++  string  cout 



8
从URL获取主机域?
如何从字符串URL获取主机域? GetDomain具有1个输入“ URL”,1个输出“ Domain” 例1 INPUT: http://support.domain.com/default.aspx?id=12345 OUTPUT: support.domain.com 例2 INPUT: http://www.domain.com/default.aspx?id=12345 OUTPUT: www.domain.com 范例3 INPUT: http://localhost/default.aspx?id=12345 OUTPUT: localhost
143 c#  string  url  httpwebrequest  uri 



6
Android,如何将字符串转换为日期?
每当用户启动应用程序时,我都会将当前时间存储在数据库中。 Calendar c = Calendar.getInstance(); String str = c.getTime().toString(); Log.i("Current time", str); 在数据库端,我将当前时间存储为字符串(如您在上面的代码中看到的)。因此,当我从数据库加载它时,需要将其强制转换为Date对象。我看到了一些所有人都使用“ DateFormat”的示例。但是我的格式与日期格式完全相同。因此,我认为没有必要使用“ DateFormat”。我对吗? 无论如何,有没有直接将此String转换为Date对象?我想将此存储时间与当前时间进行比较。 谢谢 ======> 更新 谢谢亲爱的家伙们。我使用以下代码: private boolean isPackageExpired(String date){ boolean isExpired=false; Date expiredDate = stringToDate(date, "EEE MMM d HH:mm:ss zz yyyy"); if (new Date().after(expiredDate)) isExpired=true; return isExpired; } private Date stringToDate(String aDate,String aFormat) { if(aDate==null) …
142 android  string  date  casting 

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.