string-manipulation

Split string var

Hi, I have a question: Let's say I have this string var: string strData = "1|2|3|4||a|b|c|d" Then, I make a Split: string[] strNumbers = strData.Split("||"); //something like this, I know It's not this simple I need two separate parts, each one containing this: //strNumbers -> {"1","2","3","4"},{"a","b","c","d"} So that after t...

PHP: Format a numeric string by inserting comma

I need a way to convert a number into formatted way by inserting comma at suitable places. Can it be done using regex? Example: 12345 => 12,345 1234567 =>1,234,567 ...

A specific string format with a number and character together represeting a certain item

Hello there, I have a string which looks like this "a 3e,6s,1d,3g,22r,7c 3g,5r,9c 19.3", how do I go through it and extract the integers and assign them to its corresponding letter variable?. (i have integer variables d,r,e,g,s and c). The first letter in the string represents a function, "3e,6s,1d,3g,22r,7c" and "3g,5r,9c" are two separ...

Is there a native function to get the prefix numbers in javascript?

'123xswer' How to retrieve 123 from the string above without using regular expression? ...

Request is not generated fro m jsp page

Hiii.... I am developing small spring application. I have to store the details of the student information in the database. I have develop one simpleformcontroller. I have used netbeans + hibernate mapping + spring. when I submit the form, jsp page is redirect on the same page and control does not go to Formcontroller.. ...

php string-manipulation (clear the "_" and the timestamp)

Hi! I cant find the way how to strip the useless section of my string (read from SQL) I've tried the strreplace and truncate but those was not good at all. I've got a string variable called $stuff if $stuff = 145_timestamp i want to clear the _ and the chars after it. so i want to $stuff be 145 only. Thanks. ...

How might I escape Unicode characters in a JSON string using JavaScript?

JSON String: { "id":31896, "name":"Zickey attitude - McKinley, La Rosi\u00e8re, 21 ao\u00fbt 2006", ... } this causes an unterminated string in JavaScript. My attempt at a solution is: data.replace(/(\S)\1(\1)+/g, ''); or data.replace(/\\u([0-9A-Z])/, ''); any ideas/solution? Example: http://api.jamendo.com/get2/id...

What is the most efficient algorithm for reversing a String in Java?

I am wondering which way to reverse a string in Java that is most efficient. Should I use some sort of xor method? The easy way would be to put all the chars in a stack and put them back into a string again but I doubt that's a very efficient way to do it. And please do not tell me to use some built in function in Java. I am interested i...

How do I find the last occurrence of a substring in an NSString?

How would I get the last occurrence of an NSString within another NSString? For example, in "abc def ghi abc def ghi," I want to find the index of the second "abc," not the first. I know I could do this with a bunch of rangeOfStrings, but is there already a function for that? ...

Regex for circular replacement

How would you use regex to write functions to do the following: Replace lowercase 'a' with uppercase and vice versa If easily extensible, do this for all letters Where words are separated by whitespaces and > and < are special markers on some words, replace >word with word< and vice versa. If it helps, you can restrict input such th...

Regarding String manipulation

I have a String str which can have list of values like below. I want the first letter in the string to be uppercase and if underscore appears in the string then i need to remove it and need to make the letter after it as upper case. The rest all letter i want it to be lower case. "" "abc" "abc_def" "Abc_def_Ghi12_abd" "abc__de" "_" Ou...

Convert a number to its string representation[PHP]

I'm developing a simple web application where in I need to display number a to my users in string format. Example: 12 - One Two or Twelve -20 - minus Two zero or minus twenty Either way is fine. I need this to be done in PHP. Any help will be appreciated. ...

What's the best way to replace the first letter of a string in Java?

I'm trying to convert the first letter of a string to lowercase. I know there's a capitalize method, but I want to accomplish the opposite. This is the code I used: value.substring(0,1).toLowerCase() + value.substring(1) Effective, but feels a bit manual. Are there any other ways to do it? Any better ways? Any Java string functions th...

rb_str_modify() equivalent in the Ruby language

I was trying to add a method to the String class. This method should mutate the current string (of course it would be possible to write a not mutating version but I'd prefer the mutating one). I had no idea how to do this and after some googling I found the method rb_str_modify which makes a given string mutable. That's exactly what I ne...

Howto remove HTML <a> tags in a CDATA element

Hi, I have HTML in a CDATA element (HTML is too crappy to be parsed) and I would like to remove <a href> tags, but keep text in the tags. I'm searching around regex but still not find a good way to do that. All advices are welcome! ...

String useless character strip - PHP

Hi! I've got a huge problem. I made a special ID for the things in our webpage. Let's see an example: H0059 - this is the special ID called registration number. The last two chars are the things' id. I'd like to cut off the useless characters, to get the real ID, what means strip the first char, and all the 0s before any other number...

How to remove all special characters from URL?

Hello all. I have my class public function convert( $title ) { $nameout = strtolower( $title ); $nameout = str_replace(' ', '-', $nameout ); $nameout = str_replace('.', '', $nameout); $nameout = str_replace('æ', 'ae', $nameout); $nameout = str_replace('ø', 'oe', $nameout); $nameout = ...

Faster way to split a string and count characters using R?

I'm looking for a faster way to calculate GC content for DNA strings read in from a FASTA file. This boils down to taking a string and counting the number of times that the letter 'G' or 'C' appears. I also want to specify the range of characters to consider. I have a working function that is fairly slow, and it's causing a bottleneck...

Retrieve string from the middle of a string

I have a coded string that I'd like to retrieve a value from. I realize that I can do some string manipulation (IndexOf, LastIndexOf, etc.) to pull out 12_35_55_219 from the below string but I was wondering if there was a cleaner way of doing so. "AddedProject[12_35_55_219]0" ...

String formatting error

Using the code print('{0} is not'.format('That that is not')) in Python 3.1.1, I get the following error: AttributeError: 'str' object has no attribute 'format' when I delete the line Netbeans automatically inserted at the beginning: from distutils.command.bdist_dumb import format which itself causes an error of ImportError: canno...