For eg., i have alphanumeric string 'ABCDEF 0 0.450' and i need to get '0.450' as numeric decimal and do arithmetic on it. Do we have a way? Please suggest.
I want to convert a string such as 'a=b,a=c,a=d,b=e' into a dict of lists {'a': ['b', 'c', 'd'], 'b': ['e']} in Python 2.6.
My current solution is this:
def merge(d1, d2):
for k, v in d2.items():
if k in d1:
if type(d1[k]) != type(list()):
d1[k] = list(d1[k])
d1[k].append(v)
else:
d1[k] = list(v)
return d1
record = 'a=b,a=c,a=d,b=e'
print reduce(merge, map(dict,[[x.split('=')] for x in record.split(',')]))
which I'm sure is unnecessarily complicated.
Any better solutions?
I have a hex string(lenght 48 chars) i want to convert to raw bytes with the pack function in order to put in in win32 vector of bytes.
could someone help how i can do this with perl ?
I have a string something like this:
"2014-01-23 09:13:45|\"10002112|TR0859657|25-DEC-2013>0000000000000001\"|10002112"
I would like to split by pipe apart from anything wrapped in double quotes so I have something like (similar to how csv is done):
[0] => 2014-01-23 09:13:45
[1] => 10002112|TR0859657|25-DEC-2013>0000000000000001
[2] => 10002112
I would like to know if there is a regular expression that can do this?
I have a JsonResult that is working fine, and returning JSON from some POCO's. I want to save the JSON as a string in a DB.
public JsonResult GetJSON()
{
JsonResult json = new JsonResult
{
Data = GetSomPocos()
};
return json;
}
I need to audit the response, so I want to save the json into a DB. I am having trouble finding a way to get the JSON as a string.
Any help is appreciated.
Is there any way to create a hash of string at compile time using the C/C++ preprocessor (or even template-metaprogramming)?
e.g. UNIQUE_SALT("HelloWord", 3DES);
The idea is that HelloWorld will not be present in the compiled binary, just a hash.
I have time from DB:
string user_time = "17:10:03"; //Hours:minutes:seconds
DateTime time_now = DateTime.Now;
How do I compare the time? How make same like this:
if(time_now > user_time)
{
//Do something
}
else
{
//Do something
}
How to get ride of all BBcodes in a string but keep the content?
Example:
[B]This is bold[/B] and This is [color=#FFCCCC]colored[/color]
Will be :
This is bold and This is colored
HI,
I have a string:
NEW ALPINESTAR?S SMX PLUS WHITE
MOTORCYCLE BOOTS! 44/9.5$349.95 Time
Left 1h 2m NEW AGV BLADE FLAT MATTE
WHITE LARGE/LG HELMET$75.53Time Left
1h 2m
I want result in array like this:
Productname
Price time NEW ALPINESTAR?S SMX
PLUS WHITE MOTORCYCLE BOOTS! 44/9.5
$349.95 Time Left 1h 2m
How to Find more than one string with Excel with the graphical interface?
For example, I am looking for the cells which is contained both strings Paul and John?
I am using spring mvc in which i convert the arraylist into json string. I have one object 1) results.
My output from spring looks like this:
{
"data":"[{\"userName\":\"test1\",\"firstName\":\"test\",\"lastName\":\"user\"}, {\"userName\":\"test2\",\"firstName\":\"test1\",\"lastName\":\"user1\"}]",
}
I get output as null when i do '$.parseJSON' with this output. When i tried testing only with data object it works fine
Any help would be great.
Given a string named line whose raw version has this value:
\rRAWSTRING
how can I detect if it has the escape character \r? What I've tried is:
if repr(line).startswith('\r'):
blah...
but it doesn't catch it. I also tried find, such as:
if repr(line).find('\r') != -1:
blah
doesn't work either. What am I missing?
thx!
In my code I need to compare string letters but my problem is that lower case letters are greater than upper case letter.
For example Z < a.
How could I implement this in my code ?
Thanks
If I have 5 String variables and between 0 and 5 of them are null or empty is there an easy/short way of returning the first one that is not null or empty? I am using .NET 3.5
Hi. Is there a way to convert '@my_variable' string into a value of @my_variable?
I have a table which stores names of variables. I need to get the value of this variable. Something like this:
DECLARE @second_variable AS NVARCHAR(20);
DECLARE @first_variable AS NVARCHAR(20);
SET @first_variable = '20';
SET @second_variable = SELECT '@first_variable'; --here I want that @second variable be assigned a value of "20".
How can I split a string only once, i.e. make "1|Ceci n'est pas une pipe: | Oui" parse to: ["1", "Ceci n'est pas une pipe: | Oui"]?
The limit in split doesn't seem to help...
Hello,
I want to know how to echo a string that have a $ sign from a database. At this time, the value on database 'Buy one for $5.00' converts to 'Buy one for .00'.
Ex:- Field: title | Value: Buy one for $5.00
<?php
$row = mysql_fetch_array.....
$title = $row['title'];
echo $title;
?>
Thank you, pnm123
How can I instantiate an anonymous object while passing the propertynames and values as string?
new With { .SomeProperty = "Value" }
new With { ".SomeProperty" = "Value" } //something like this? :)
I want to sort a list of strings based on the string length. I tried to use sort as follows, but it doesn't seem to give me correct result.
xs = ['dddd','a','bb','ccc']
print xs
xs.sort(lambda x,y: len(x) < len(y))
print xs
['dddd', 'a', 'bb', 'ccc']
['dddd', 'a', 'bb', 'ccc']
What might be wrong?
Hi all,
i have a little question ,i have a NSString object
(\n "1 Infinite Loop",\n "Cupertino, CA 95014",\n USA\n)
and i want the Cupertino from this string
Till now i have used stringByReplacingOccurrencesOfString: and able to get "1InfiniteLoop""CupertinoCA95014"USA
But still not able get Cupertino.
Do any other method able to solve this problem?
Hi, I have a string and I want to check if it represents a proper namespace, eg. System.IO is ok, but System.Lol is not.
I guess some reflection should be used, but I can't figure this out.
Any thoughts?