string-manipulation

Counting a certain character in a String (Java)

String a="(Yeahhhh) I have finally made it to the (top)"; Given above String, there are 4 of '(' and ')' altogether. My idea of counting that is by utilizing String.charAt method. However, this method is rather slow as I have to perform this counting for each string for at least 10000 times due to the nature of my project. Anyone has ...

string aggregation in Oracle 10g

How to aggregate string( concatenate) with Oracle 10g SQL? ...

What's the best way to remove portions of a string? (C#)

I am looping through an array and there is a string in there that reads like this example: "1001--Some ingredient". Right now, as I loop through the array I am getting the whole string string ingCode = theData[i + 1]; But what I really need is simply "1001" and not the whole shibang. ...

Benefits to NOT trimming strings of leading and trailing white spaces in database applications

I am not a developer, but I have spent years testing and managing software projects. Bugs caused by leading and trailing white space in strings are like war wounds that will never completely heal. So I ask, in what situations are leading and trailing white spaces beneficial? ...

bash: filter away consecutive lines from text file

I want to delete from many files each instance of a paragraph. I call paragraph a sequence of lines. For example: my first line my second line my third line the fourth 5th and last the problem is that I only want to delete them when they appear as a group. For example, if my first line appears alone I don't want to delete it. ...

XML Parsing: Checking for strings within string C++

I have written a simple C++ shell program to parse large XML files and fix syntax errors. I have so far covered everything I can think of except strings within strings, for example. <ROOT> <NODE attribute="This is a "string within" a string" /> <ROOT> My program loops through the entire xml file character by character(keeping only ...

Replace Second Instance of String

Hey, I just wondering how I could replace the second instance of a string inside a string in php such as follows: a - b - c Where it would add an extra space after the second "-" but only if it finds 2. Thanks ...

First character uppercase Lua

Does Lua provide a function to make the first character in a word uppercase (like ucfirst in php) and if so, how to use it? I want keywords[1] to be first letter uppercase. I've read that string.upper does it but it made the whole word uppercase. ...

Regarding Java Command Line Arguments

I have the below command line arguments set for the program. argument proc is mandatory argument chgval is optional and argument inputfile is optional. ./test.sh -proc mode1 -chval a -inputfile b.csv I need to modify the below function so that either one of the optional argument should exists in command line arguments along with ...

Filter string in C

How can I filter a string in c? I want to remove anything that isn't [a-z0-9_]. int main(int argc, char ** argv) { char* name = argv[1]; // remove anything that isn't [a-z0-9_] printf("%s", name); } ...

String division

Hi I want to print the string " my name is xxx" as "xxx is name my" with out using Special methods (like util package methods in java); thanks ...

Rotate a string N times in PHP

I'm looking for a way to rotate a string to the left N times. Here are some examples: Let the string be abcdef if I rotate it 1 time I want bcdefa if I rotate it 2 time I want cdefab if I rotate it 3 time I want defabc . . If I rotate the string its string length times, I should get back the original string. ...

manipulating list items python

line = "english: while french: pendant que spanish: mientras german: whrend " words = line.split('\t') for each in words: each = each.rstrip() print words the string in 'line' is tab delimited but also features a single white space character after each translated word, so while split returns the list I'm after, each word annoyin...

String.split() method bug in GWT 2.0.3

I'm upgrading a GWT project from GWT 1.7.1 to currently newest version 2.0.3. It seems that new GWT broke String.split(String regex) method - I get the following error on the Javascript side: this$static is undefined This happens in this line of my .nocache.js file: if (maxMatch == 0 && this$static.length > 0) { ...which happens to...

XSLT string parsing

Hi, Im new to XSLT for the 'PrimarySubject' below I need to replace'&' characters to %26 and ' ' characters to %20 that it contains. <xsl:template name="BuildLink"> <xsl:param name="PrimarySubject" /> <xsl:text>?PrimarySubject=</xsl:text> <xsl:value-of select="$PrimarySubject" /> </xsl:template> Is there string repla...

Regular expression to retrieve everything before first slash

I need a regular expression to basically get the first part of a string, before the first slash (). For example in the following: C:\MyFolder\MyFile.zip The part I need is "C:" Another example: somebucketname\MyFolder\MyFile.zip I would need "somebucketname" I also need a regular expression to retrieve the "right hand" par...

Need to parse a string till the end of the file

i have the following code ..i need to loop through end of the file as per the commented code shown below how i can do it ? namespace BVParser { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { StreamReader sr = new StreamReader(@"D:\Jaison\Ja...

How to join list of strings?

Hi all, This is probably seriously easy to solve for most of you but I cannot solve this simply putting str() around it can I? I would like to convert this list: ['A','B','C'] into 'A B C'. Thanks in advance!! ...

PHP Get only a part of the full path

Hello, I would like to know how can I subtract only a part of the full path: I get the full path of the current folder: $dbc_root = getcwd(); // That will return let's say "/home/USER/public_html/test2" I want to select only "/public_html/test2" How can I do it? Thanks! ...

How to evaluate the string in ruby if the string contains ruby command?

In my case, I was storing the sql query in my database as text. I am showing you one record which is present in my database Query.all :id => 1, :sql => "select * from user where id = #{params[:id]}" str = Query.first Now 'str' has value "select * from user where id = #{params[:id]}" Here, I want to parsed the string like If my pa...