string

how to create a flat file in ruby

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...

Check if space is in a string

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.. ...

fastest way to find string in C# ?

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...

How to parse out Timestamp from this String?

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...

Detecting a sequence of files

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...

How to remove email addresses and links from a string in PHP?

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. ...

how do I convert a string to a valid variable name in python ?

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...

substring match faster with regular expression?

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...

Can I divide an array or string into multiple variables?

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...

JavaScript Variable inside string without concatenation - like PHP

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. ...

Replacement of random string/char array characters using match ups.

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 Registered, Trademark, and Copyright symbols from a string?

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®'; ...

Python csv string to array

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 ...

How to manipulate string in an array

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 ...

How can I limit a string if it's larger than desired?

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...

PHP String Parsing Strip *First* enter/return space from form textarea

How do you strip the first (before any visible text) enter/return space from text taken from a variable (submitted from a textarea)? ...

Character-wise string diff in PHP

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...

Determining if a Javascript object is a "complex" object or just a string

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...

[VB.Net] ByRef vs ByVal performance when passing strings

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?...

replace string with javascript using regex

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...