substring

How to find all substrings of a string

I need to convert strings of the form "a b c" into arrays of the form Array ( [0] => a [1] => a b [2] => a b c [3] => b [4] => b c [5] => c ) Does PHP provide a native function for converting strings into all substrings? If not, what's the path of least resistance for getting all substrings? Is there a str...

PHP code to display substring of current URL?

Hello, I want to redirect my browser to a PHP page such that when the page loads, it will display to the user a substring of the current URL. For example, let's say I have a page called substring.php. My browser forwards me to: http://www.example.com/substring.php?oauth_token=123456 Is it possible to write some PHP code that will th...

Substring C from string like folder1/file1.txt

Hi all, i have strings like "folder1/file1.txt" or "foldername1/hello.txt" and i need to take the substring that identify the folder name with the slash (/) included (example: from "folder1/file1.txt" i need "folder1/"). The folders name are not all with the same length. How can i do this in C?? thanks ...

Number of occurrences of a substring in an NSString?

How can I get the number of times an NSString (for example, @"cake") appears in a larger NSString (for example, @"Cheesecake, apple cake, and cherry pie")? I need to do this on a lot of strings, so whatever method I use would need to be relatively fast. Thanks! ...

Argument data type uniqueidentifier is invalid for argument 1 of substring function

I am trying to get the first part of a Guid Field with the TSQL substring function as follows SELECT SUBSTRING(Guid, 1, 8) AS Gu FROM MyTable but all i get is this error. Argument data type uniqueidentifier is invalid for argument 1 of substring function. So what is going on here? Should i treat the Guid as pure string first or...? ...

How to make a sub string selection and concatenation in excel ?

Hello guys I have an excel file with field1 and field2 I want to take the first letter in field1 and concatenate it to field2 and put the result in field3 Example: Field1 = "John" Field2 = "Doe" I want to set the field three by some equation to be Field3 = "JDoe" ...

Finding a string within a string

How can i show this? substring?split? ... but it's maybe dynamic !!! String str = "SET ENCALSUP=NOENCR&GSMV2,MAXNCELL=16,TDTMWIND=5,MAXLAPDMN=5,EENHDTMSUP=DISABLED,T3197=4,PAGCOORCLB=DISABLED,DGRSTRGYBCNT=DISABLED,PAGQOVLIND=0;"; this output (EENHDTMSUP=DISABLED): just this DISABLED Thanks ... ...

Best technique to search for matching substrings with Linq & SQL Server

I have a requirement to find rows in a table containing 200,000 entries. Some may not consider this 'large', but it is large enough to warrant performance considerations. The table contains strings consisting of digits only. For instance, the user can enter something like '12340-0560-78', or portions of this, e.g. '0560', and I need to ...

Java parsing many instances of substring from String

Hello, I am trying to write a small java program that will accept a file (using Scanner class), return the file as a String, and then search that string for any instance of a substring starting with "Email:" and ending with ".edu". There will be many instances of this substring, each of which I want to parse out into an array or a new f...

How to replace a string at a particular position

Is there a way to replace a portion of a String at a given position in javascript.For instance I want to replace 00 in the hours column with 12 in the below string.The substring comes at 13 to 15. Mar 16, 2010 00:00 AM ...

In java, how to check if a string contains a substring , ( ignoring the case ) ?

I have two Strings: str1 and str2. How to check if str2 is contained within str1, ignoring case? ...

Java finding substring

I have the following String: oauth_token=safcanhpyuqu96vfhn4w6p9x&**oauth_token_secret=hVhzHVVMHySB**&application_name=Application_Name&login_url=https%3A%2F%2Fapi-user.netflix.com%2Foauth%2Flogin%3Foauth_token%3Dsafcanhpyuqu96vfhn4w6p9x I am trying to parse out the value for oauth_token_secret. I need everything from the equals sign ...

Remove last character from C++ string

Hi! How can I remove last character from a C++ string? I tried st = substr(st.length()-1); But it didn't work. ...

how to substring from a string using c#?

string format is always like this "FirstName=ABC;LastName=XZY;Username=User1;Password=1234". I need the only UserName value (which is 'User1' in this case). I wanna achieve this in minimum line of code using substring method (or something else). Help? ...

need help with parseInt

hello, how can i get for example the integer codeInt=082 from String code='A082' i have tried this: int codeInt = Integer.parseInt(code.substring(1,4)); and i get codeInt=82 ,it leaves the first 0 but i want the full code '082'. i thought of parseInt(String s, int radix) but i don't know how . any help will be appreciated . thanks....

How efficient is Python substring extraction?

I've got the entire contents of a text file (at least a few KB) in string myStr. Will the following code create a copy of the string (less the first character) in memory? myStr = myStr[1:] I'm hoping it just refers to a different location in the same internal buffer. If not, is there a more efficient way to do this? Thanks! Note: I'...

Split string into multiple lines

I have a long string of comments that I'd like to split into multiple lines. It's currently displayed as <%= Html.Encode(item.important_notes) %> I've played with using .Substring to split it, but can't figure out how to prevent it from splitting in the middle of a word. Instead of characters 1-100 on line 1 and 101-200 on line 2, I'...

When getting substring in .Net, does the new string reference the same original string data or does the data get copied?

Assuming I have the following strings: string str1 = "Hello World!"; string str2 = str1.SubString(6, 5); // "World" I am hoping that in the above example str2 does not copy "World", but simply ends up being a new string that points to the same memory space only that it starts with an offset of 6 and a length of 5. In actuality I am...

C++ string.substr() function problem

I want to make a program that will read some number in string format and output it like this: if the number is 12345 it should then output 12 23 34 45 . I tried using the substr() function from the c++ string library, but it gives me strange results - it outputs 1 23 345 45 instead of the expected result. Why ? #include <iostream> #incl...

tsql : how to do a substring replace?

goal: I have the string "1234432144" I want to only replace the first 2 4's with '10' so I would get '1231032144' Is there a way to do this in tsql? so far I have come up with the tsql substring() function substring('1234432144', 4, 2) which draws the 44 .. however how do i replace it within the existing string? If i wrap a r...