string

Python: Parsing JSON String List for Each JSON Object

I use the json module and the dumps method to obtain a string which represents a list of json objects : import json jsonstring = json.dumps(data) I would like to iterate over this string to obtain each JSON object as a string. Any suggestions? Thanks in advance. P.S. I have tried the following: for jsonobject in jsonstring: p...

How can I convert a string array to a variant array in VBscript?

I'm using a function in vbscript which returns a variant array of strings. JobIDs = objDoc.ConnectedSubmit(objServer) The problem is I can't get the Job ID values from that array, as vbscript doesn't handle typed variables. It just gives a type mismatch when I attempt to do ANYTHING with the JobIDs array. I found some promising info...

Converting a C (\0 terminated) string to a PHP string

PHP is one of those languages I use periodically, but usually have to dust the cobwebs off when I start using it again. The same applies this week whilst I port some C code to PHP. This uses a lot of AES encryption and SHA256 hashing - all working fine so far. However, decrypted strings come out in "C" form - i.e. terminated with a zero ...

Java recognizing address information and breaking it apart into variables (no regex)

Hello, Does anyone have a recommended pseudo-algorithm for, given a string containing an address: Break apart the address apart into a Street variable, a City variable, a State variable, and a Zip variable The address string may be formatted in a number of different ways. For example, it may be comma separated or it may be separated b...

Is there any way to pass a std::string to a function that accepts a char* and changes its contents?

I'm trying to get back into programming, specifically console games. I'd heard that curses was good for that, so I found a curses tutorial and I'm getting into that. I'm using C++, and naturally I wanted to take advantage of std::string, but functions like getstr() only accept char*. Is there any way to pass a string as a char*, or am I ...

Minimize LINQ string token counter

Followup on answer to an earlier question. Is there a way to further reduce this, avoiding the external String.Split call? The goal is an associative container of {token, count}. string src = "for each character in the string, take the rest of the " + "string starting from that character " + "as a substring; count it if it s...

ruby: overriding strings' methods returning nil (strip!, upcase!, downcase!, capitalize!, chop!, chomp!, delete!, gsub!)

Those stupid 'string'.method! returning nil instead of self in ruby - can be easily overriden: class String ['strip!', 'upcase!', 'downcase!', 'capitalize!', 'chop!', 'chomp!', 'delete!', 'gsub!'].each do |meth| orig_meth = "orig_#{meth}" alias_method orig_meth, meth define_method(meth) do |*args| ...

PHP parse error

i am trying to get player logic in place with those if statements player 1 fires 1st -> player 2 2nd then start over again (an user checks a box)then the unset removes the pieces from the board as they are hit Parse error: syntax error, unexpected '(', expecting ']' in on line 93 the problem is this line of code: ...

Question on importing strings

I'm learning Xcode through templates and incorporating the codes in my app. Anyways this template I'm learning from has a string file under the groups and files. I tried to import that file into my project but it doesn't show up. So my question is which file do I need to create to make this string file? Do I just get a regular .m file an...

XSLT parse text node as XML?

In the middle of an XML document I'm transforming, there is a CDATA node which I know itself is composed of XML. I would like to have that "recursively parsed" as XML so that I can transform it too. Upon searching, I think my question is very similar to http://stackoverflow.com/questions/1927522/handling-node-with-inner-xml-in-xslt. T...

Simple Java regex not working.

Hello all, I have this regex which is supposed to remove sentence delimiters(. and ?): sentence = sentence.replaceAll("\\.|\\?$",""); It works fine it converts "I am Java developer." to "I am Java developer" "Am I a Java developer?" to "Am I a Java developer" But after deployment we found that it also replaces any other dots in th...

How should I manage password strings in .net?

I know there is the SecureString class, but for most scenarios I don't think it's really useful. For example, let's say I have a client/server system. The server doesn't need an application made by me, it could be even SQL Server without integrated authentication. When the user enters his password on a form in the client app, it's store...

How to convert a decimal number to hex string in Perl?

For example I would like to convert 2001 into: "0x07", "0xD1" Thanks ...

How can I update parts of the string that matches some regexp

Hi, I have string "(1,2,3,4,5,6),(1,2,3)" I would like to change it to "('1','2','3','4','5','6'),('1','2','3')" - replase all parts that mathces /([^,)("])/ with the '$1', '$2' etc ...

passing a string literal to a function that takes a std::string&

I have the following function void AddNodeValue(XMLNode& node, std::string& value); I want to use it like this: document.AddNodeValue(modvalue,"modvalue"); and the compiler complains: error C2664: 'void XML::XMLDocument::AddNodeValue(XML::XMLNode &,std::string &)' : cannot convert parameter 2 from 'const char [9]' to 'std::stri...

regex delete heading and tailing punctuation

I am trying to write a regex in Java to get rid of all heading and tailing punctuation characters except for "-" in a String, however keeping the punctuation within words intact. I tried to replace the punctuations with "", String regex = "[\\p{Punct}+&&[^-]]"; right now, but it will delete the punctuation within word too. I also trie...

HTML Formatting in the Automated Mail Content

StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); String rowFormat = "%8s %8s %8s %8s%n"; pw.printf(rowFormat, "Col A", "Col B", "Col C", "Col XY"); pw.printf(rowFormat, "A", "19", "Car", "55"); pw.printf(rowFormat, "X", "21", "Train C", "-4"); pw.printf(rowFormat, "B", "-9", "Bike", "0"); String message = sw.t...

Regex match that must contain all characters in a string

I'm sure this has already been asked and answered, but I honestly couldn't find my answer after searching for quite a bit and reading Regex Tutorial. What I'm looking to do is match a string that has the same characters and length as another string. For example, a string "abcde" would match "edcba" but would not match "abcdf" or "aabbc...

regex help, find first 3 occurrences of a keyword and str_ireplace the content

Given a block of text, I need to parse it for the existing of a keyword. Then on the first appearance of the keyword, I need to wrap bold tags around it (if it doesn't already have them), on the second appearance of the keyword, italics, and on the third, underline. Example using the keyword "help": This is some text with the keyword "...

How are text editors generally implemented?

This question is probably going to make me sound pretty clueless. That's because I am. I'm just thinking, if I were hypothetically interested in designing my own text editor GUI control, widget, or whatever you want to call it (which I'm not), how would I even do it? The temptation to a novice such as myself would be to store the conte...