how can I create a flat file in ruby?
Flat file is there each letter is placed at a specific column number in the file.
So for example if I am reading some values from the DB:
Name Class
-------------------
one A
two English
three Math
four Science
and I want to make a flat file out of it wh...
http://paste.pocoo.org/show/240061/
I'm writing a program that checks whether the string is a single word. Why doesn't this work and is there any better way to check if a string has no spaces/is a single word..
...
What is the fastest way to implement something like this in C#:
private List<string> _myMatches = new List<string>(){"one","two","three"};
private bool Exists(string foo) {
return _myMatches.Contains(foo);
}
note, this is just a example. i just need to perform low level filtering on some values that originate as strings. I...
I have this sample string:
Sample string 1:
A^1.1#B^1#I^2#f^0#p^1#d^2010-07-21T08:52:05.222ZKHBDGSLKHFBDSLKFGNIF#%$%^$#^$XLGCREWIGMEWCERG
Sample string 2:
A^1.1#B^1#f^0#p^1#d^2010-07-22T07:02:05.370ZREGHCOIMIYR$#^$#^$#^EWMGCOINNNNNNVVVRFGGYVJ667VTG
So, from these strings, I need to take out the time stamp:
2010-07-21T08:52:05.222 or...
I need to import file sequences into a Qt program. Import itself is not hard, but I'm pondering what might be the most easiest way to detect if the files form a sequence, e.g.:
filename_00001.png
filename_00002.png
filename_00003.png
etc.
Now, I have a drag'n'drop import working, and I'm sorting the list of imported files alphabetical...
Hi, i need to remove all email addresses and links from a string and replace them with "[removed]" and i'm a bit lost on how to do it.
Can someone help me on this?
Thanks.
...
Python n00b here
I need to convert an arbitrary string to a string that is a valid variable name in python.
Here's a very basic example:
s1 = 'name/with/slashes'
s2 = 'name '
def clean(s):
s = s.replace('/','')
s = s.strip()
return s
print clean(s1)+'_'#the _ is there so I can see the end of the string
That is a very n...
Hello,
After having read up on RE/NFA and DFA, it seems that finding a substring within a string might actually be asymptotically faster using an RE rather than a brute force O(mn) find. My reasoning is that a DFA would actually maintain state and avoid processing each character in the "haystack" more than once. Hence, searches in long...
Here's where I've been:
I made a PHP client call via soap to retrieve an array of data,
I successfully receieved and converted my array to JSON via json_encode,
I then echoed it back to my page.
Here's where I am:
I get back my array in this format...
{"MethodName":"ID,11|1|Item1,22|2|Item2,33|3|Item3"}
Here's where I want to be:
Using...
I know in PHP we can do something like this :
$hello = "foo";
$my_string = "I pity the $hello";
output : "I pity the foo"
I was wondering if this same thing is possible in JavaScript as well. Using variables inside strings without using concatenation -- it looks more concise and elegant to write.
...
while (1)
{
char j;
if (x[j] == y[j])
Here I am trying to start a loop where I want to able to match any of the characters from char array 'x' with char array 'y'. If the characters do match from x to y then I want to keep them as they are and if they don't I want to be able to replace them with a star '*'. (e.i. x = [a,p,f] an...
What's the best way to remove symbols, like the Registered, Trademark, and Copyright symbols from a string?
For instance I'd like to strip the ® out of the following: $string = 'Can't Touch This®';
...
Anyone know of a simple library or function to parse a csv encoded string and turn it into an array or dictionary?
I don't think I want the built in csv module because in all the examples I've seen that takes filepaths, not strings.
Thank you
...
I have an array that contain some fields
like this
ctl00_ctl00_cphBody_bodycph_content_rdo_SID_25_SortOrder_17
ctl00_ctl00_cphBody_bodycph_content_rdo_SID_25_SortOrder_18
ctl00_ctl00_cphBody_bodycph_content_rdo_SID_25_SortOrder_19
I want to create a new array or manipulate this array to contain only
sid = {25,26,27}
from
_SID_25
...
I currently have a string that I want to limit to 200 characters.
I don't know how to format it so if it's less, it wont change, but if its more, it will trim it.
This is in a ListView Control, NOT a Repeater. Sorry for that, my mistake.
<ItemTemplate>
<div class="portfolio_title">
<div class="custom_title">
<%# DataBinder.Eval(Contai...
How do you strip the first (before any visible text) enter/return space from text taken from a variable (submitted from a textarea)?
...
In short I am looking for something like google-diff-match-patch in PHP.
I have had a look at some similar questions at SO, and also at the algorithm provided here, but all of them fail:
diff("draßen", "da draußen")
should not give
<del>draßen</del> <ins>da draußen</ins>
(which is kind of stupid for my purpose, because I want to...
I want to be able to pass either a string literal,
'this is a string'
or a javascript object,
{one: 'this', two: 'is', three: 'a', four: 'string' }
as argument to a function, and take different actions depending on whether it's a string or an object. How do I determine which is true?
To be specific, I want to iterate over the prop...
Hello everyone!
Reading http://stackoverflow.com/questions/408101/which-is-faster-byval-or-byref made me wonder whether the comments in there did apply to Strings in terms of performance. Since strings are copied before being passed, isn't it much more efficient (if the callee doesn't need a copy of string course) to pass strings ByRef?...
Hi
I have text inside "textarea" and I was trying to remove the text between: <textarea></textarea> using replace function with some regex. here is what I did so far:
x = '<TEXTAREA style="DISPLAY: none" id=test name=test>teeeeessst!@#$%&*(LKJHGFDMNBVCX</TEXTAREA>';
x.replace('/<TEXTAREA style="DISPLAY: none" id=test name=test>.*</TEXT...