string-manipulation

python to uncomment the right line

Hi, guys, I have a file as follows: line 1: _____ ... # for AAA #export CONFIG = AAA_defconfig # for BBB, BbB, Bbb, BBb3 #export CONFIG = BBB_defconfig # for CCC, CcC, Ccc, Ccc1 #export CONFIG = CCC_defconfig ... other lines I want manipulate the file, so that based on the given string, I could export the right "CONFIG", and...

Replace a variable string with empty string

I have an xml file that I am using linq-to-XML to read. Linq-to-XML is preserving the line breaks and spaces for indenting. So instead of having a guid like this: "FB5417E2-DB15-481d-80D6-D0C4CB26EB1F" I am getting stuff like this: "\n FB5417E2-DB15-481d-80D6-D0C4CB26EB1F" I have made this method to try and help compensate fo...

Remove characters after string?

I have strings that looks like this: John Miller-Doe - Name: jdoe Jane Smith - Name: jsmith Peter Piper - Name: ppiper Bob Mackey-O'Donnell - Name: bmackeyodonnell I'm trying to remove everything after the second hyphen, so that I'm left with: John Miller-Doe Jane Smith Peter Piper Bob Mackey-O'Donnell So, basically, I'm trying to ...

JavaScript manipulate string problem

var a var a = "ACdA(a = %b, ccc= 2r2)"; var b var b = "\ewfsd\ss.jpg" Expected outputs: var c = "ACdA(a = %b, ccc= 2r2, b_holder = \ewfsd\ss.jpg)" It adds the string b to the end of string a, that's it! But be careful of the ")" "b_holder " is hard coded string, it's absolutly same in all cases, won't be changed. Thanks ever...

replace strings inside a substring

Hi. I have this string: "The quick brown f0x jumps 0ver the lazy d0g, the quick brown f0x jumps 0ver the lazy d0g.". I need a function that will replace all zeros between "brown" and "lazy" with "o". So the output will look like this: "The quick brown fox jumps over the lazy d0g, the quick brown fox jumps over the lazy d0g.". So it wil...

PHP function to replace a (i)th-position character

Hello all Is there a function in PHP that takes in a string, a number (i), and a character (x), then replaces the character at position (i) with (x)? If not, can somebody help me in implementing it? Thanks. ...

Finding the border of a string

Firstofall let me tell you what a border of string is. Let x = abacab. The borders of x are ε, ab . That is a border of a string is a substring which is both a prefix and suffix of it. for e.g. In string abcde hgrab edcba abcde is prefix as well as suffix .Thus it is also the border of above string. Guys please could somebody help me...

Is it possible to concatenate heredoc string in PHP..?

With normal PHP string you can do this: $str = "Hello "; $str .= "world"; $str .= "bla bla bla"; $str .= "bla bla bla..."; But can you do the same with heredoc string..? $str = <<<EOD Hello world EOD; $str .= <<<EOD bla bla bla"; bla bla bla..."; EOD; ...

Get an acronym from a string in C# using LINQ?

Here is how I would write a function to make an acronym in Java style: string makeAcronym(string str) { string result = ""; for (int i = 0; i < str.Length; i++) { if (i == 0 && str[i].ToString() != " ") { result += str[i]; continue; } ...

How to convert a String into a String[][]

I have a string like this: String string ='{{"INPUT FILE", "NUMBER OF RECORDS"},{"Item File", "11,559"},{"Vendor File", "300"}, {"Purchase History File", "10,000"},{"Total # of requisitions", "10,200,038"}}'; And I want to convert it into an array like this: String [][] data = { {"INPUT FILE", "NUMBER OF RECORDS"}, ...

Flattening columns in a one-to-many relationship in Oracle 10g

I'm guessing this is a matter of figuring out what oracle command to use, but after a couple of hours of googling, I haven't found anything that can do what I need. So here's what I need to have happen in a nutshell: Table 1 Table 2 | PrjID | | PrjID | UserID | |----------| |----------|------...

Increment last letter of a string

Here's where I wish Java's String class had a replaceLast method, bu it doesn't and I'm getting the wrong results with my code. I'm writing a program that searches a data structure for any items that match a string prefix. However, since I'm using an Iterator, the last item returned by the iter.next() call doesn't match the pattern, so...

Web service in iphone

i have a webservice and implementing that ,but when i get the array from this weservice its showing characters like this line brake in some keys. I am trying to replace that with stringbyreplacing occurance of string but nothing happens. Could anyone help me for this to replace this type of characters,show that when u want to sho...

Replacing whitespaces within list elements

I have a list of tags: >>> tags_list ['tag1', 'second tag', 'third longer tag'] How can I replace whitespaces within each element of the list with "+" ? I was trying to do this with regular expressions but each string remains unchanged: for tag in tags_list: re.sub("\s+" , " ", tag) What is wrong with my approach ? EDIT: Yes ...

PHP - String manipulation remove spcial characters and replace spaces

I am getting strings from a database and then using the strings to build a URL. My issue is, some of the strings will have characters like < > & { } * general special characters, but the string may also have strings in. How would I replace the spaces with dashes and totally remove and special characters from the strings? ...

php remove from string

Nice quick one for you guys, hope you can help. After a dodgy CMS I created a while ago, my database is full of product 'names' that have either 1, 2 or 3 spaces before the actual name. This is causing me havoc now and I'm wondering if there's a function that will let me remove these pesky spaces in PHP instead of having to update the d...

C++, substract certain strings?

Hi, This is a homework, thus I hope you guys dont give me the direct answers/code, but guide me to the solution. My problem is, I have this XXX.html file, inside have thousands of codes. But what I need is to extract this portion: <html> ... <table> <thead> <tr> <th class="xxx">xxx</th> <th>xxx</th...

How to pad with n characters in Python

I should define a function pad_with_n_chars(s, n, c) that takes a string 's', an integer 'n', and a character 'c' and returns a string consisting of 's' padded with 'c' to create a string with a centered 's' of length 'n'. For example, pad_with_n_chars(”dog”, 5, ”x”) should return the string "xdogx". ...

Get the HTML value which is not in a tag in c#

I have an HTML string that has the following form: <tr valign="top"><td colspan="2" style="padding-bottom:5px;text-align: left"><label for="base_1001013" style="margin-bottom: 3px; float: left">Nom d'utilisateur:&nbsp;</label><span style="float: right;"><input class="PersonalDetailsClass" type="text" name="base_1001013" id="base_1001...

Copying alhpanumeric chars in C

Hey, this should be pretty simple but getting stuck. Have a char array of text, want to store the alphanumeric lowercase value in a pointer array. ie mystr should point to a char[] of "50sometexthere" char[] myline = " 50 Some Text Here "; char *mystr = (char *)malloc(128 * sizeof(char)); char *tmp = myline; while (*tmp != '\0'){ i...