string

PHP - Error parsing a string with code

I'm having a problem with some code that used to work in PHP 4.X and is not working in PHP 5.2.4 First of all, there is a small example of a code similar to the one is causing the problem. Unfortunately, I haven't been able to reproduce the problem with a small example. <?php class Example{ public function showExample() { $ind...

How to write an object to file in C++

I have an object with several text strings as members. I want to write this object to the file all at once, instead of writing each string to file. How can I do that? ...

Regular expression, remove the last specific character in the string with jQuery

I want to continue one task because my head has some problem with a regular expression. How can it be done with a regular expression and jQuery? I have this HTML: <div class="test">&nbsp;&gt;&nbsp;&nbsp;&gt;&nbsp;Presentation Text </div> And I want to get just this text from all this string, every time at the beginning I have " &...

C# way to convert char into 8x8 binary

Hi guys, Can you help me look for a way to convert char into 8x8 binary (am not sure how to call it) like for example an "A" 00011000 00100100 00100100 01000010 01111110 10000001 10000001 10000001 am actually doing this manually :( suggestions are still open :D EDIT: Anyway, if you guys are wondering what am trying to do. Am try...

Can I do an easy init a string with format using @" ...

Hi, when defining a string in Objective-C, can I do an easy assignment using a string format, such as NSString *myVar = @"My String has %d words", 4; ...

Ruby String accent error: More than meet the eyes

I'm having a real trouble to get accents right, and I believe this may happen to most Latin languages, in my case, portuguese I have a string that come as parameter and I must get the first letter and upcase it! That should be trivial in ruby, but here is the catch: s1 = 'alow'; s1.size #=> 4 s2 = 'álow'; s2.size #=> 5 s1[0,1] #=> "a"...

Ruby parse string

I have a string input = "maybe (this is | that was) some ((nice | ugly) (day |night) | (strange (weather | time)))" How is the best method in Ruby to parse this string ? I mean the script should be able to build sententes like this : maybe this is some ugly night maybe that was some nice night maybe this was some strang...

Xml Calling with jQuery, (invalid XML)

Hi All, I have one problem , I want to get some data from XML file (if I can say that it is XML file), with jQuery: This is my jQuery, it works with normal XML file : $.ajax({ type: "GET", url: "test.xml", dataType: "xml", success: function(xml) { $(xml).find('result').each(function(){ ...

Algorithm: Split a string into N parts using whitespaces so all parts have nearly the same length

I am looking for a algorithm that takes a string and splits it into a certain number of parts. These parts shall contain complete words (so whitespaces are used to split the string) and the parts shall be of nearly the same length, or contain the longest possible parts. I know it is not that hard to code a function that can do what I wa...

Long Pointer to Constant Wide String, what's the function of the Long here?

When you have a LPCWSTR, why is it a Long Pointer? There's no Long in it's definition, as far as I know. Can anybody explain? ...

Simple regex question to parse similar things in .NET?

Is there a way to gather all links that has a specific domain in a string where they only include ones that are either: href="http://yahoo.com/media/news.html" or >http://yahoo.com/media/news.html&lt; So basically links either prefixed by href=" and ends with " or links that are surrounded by ><. I tried to use Regex ( "href=\"(...

How to add all items in a String array to a vector in Java ?

My code looks like this : Vector<String> My_Vector=new Vector<String>(); String My_Array[]=new String[100]; for (int i=0;i<100;i++) My_Array[i]="Item_"+i; ...... My_Vector.addAll(My_Array); But I got an error message, what's the right way to do it, without looping to add each item ? Frank ...

Regarding java file closing

i noticed in a java program the below line used to open a file and process it BufferedReader inp = new BufferedReader(new FileReader(inputFile)); In the javaprogram the inp is not closed before exiting the program the below line is missing if (inp != null) try { inp.close(); } catch (IOException logOrIgnore) {} Th...

How do I find the number of bytes within UTF-8 string with PHP?

I have the following function from the php.net site to determine the # of bytes in an ASCII and UTF-8 string: <?php /** * Count the number of bytes of a given string. * Input string is expected to be ASCII or UTF-8 encoded. * Warning: the function doesn't return the number of chars * in the string, but the number of bytes. * ...

vb.net convert value to string

Not sure how to do this, here is my code Dim oWeb As New System.Net.WebClient() oWeb.Headers.Add("Content-Type", "application/x-www-form-urlencoded") Dim bytArguments As Byte() = System.Text.Encoding.ASCII.GetBytes("username=username&password=password") Dim bytRetData As Byte() = oWeb.UploadData("https://www.website.com",...

strtok giving Segmentation Fault

Hi, Why does the below code give Seg. Fault at last line? char* m=ReadName(); printf("\nRead String %s\n",m); // Writes OK char* token; token=strtok(m,'-'); As said, read string prints w/o problem, but why cannot split to tokens? ...

Simplest way to validate a GPS string in C++?

I have some MET data I want to validate which would look something like these: char validBuffer[] = {"N51374114W1160437"}; char invalidBuffer[] = {"bad data\n"}; char emptyBuffer[] = {""}; I've tried a simple sscanf, but that failed: int _tmain(int argc, _TCHAR* argv[]) { char validBuffer[] = {"N51374114W1160437"}; char inva...

Find the first letter of the last word with jquery inside a string (string can have multiple words)

Hy, is there a way to find the first letter of the last word in a string? The strings are results in a XML parser function. Inside the each() loop i get all the nodes and put every name inside a variable like this: var person = xml.find("name").find().text() Now person holds a string, it could be: Anamaria Forrest Gump John Lock As ...

case insensitive string search csharp

Hi There, What is the quickest most efficient way to search text for words using non-casesensitive search. E.g here is my text to be searched : string textTosearch = "Here is a paragraph or Some text. Here is some more text". If i wanted to find the indexes of "Some" and "some", is there a .Net class string that does this or would i nee...

Replace special string characters in jquery

HI, I have some string from XML file, and I I want to replace all "& lt;, and & gt;" ... in "< and '>" this is the AJAX call (jQuery): $.ajax({ type: "GET", url: "xml.xml", dataType: "html", success: function(xml) { alert(xml); $(xml).find('reslult').each(function(){ ...