string

Random String Generator creates same string on multiple calls

Hi there. I've build a random string generator but I'm having a problem whereby if I call the function multiple times say in a Page_Load method, the function returns the same string twice. here's the code Public Class CustomStrings ''' <summary>' ''' Generates a Random String' ''' </summary>' ''' <param name="n">number...

How to find if string contains letters and spaces (php)?

So I need to get value false or true if string contains not only letters of all european and east alphabets and " "(space) and "-" minus. How to do such thing with some $a string? ...

undefined method ‘bytes’ for for String in Ruby

I am working with ruby 1.8.6 (2007-03-13 patchlevel 0) [x86_64-linux] and I get undefined method `bytes' for #<String:0x2a95ec2268> (NoMethodError) even though my code works on ruby 1.8.7. patchlevel 249 I saw somewhere that you need to add require "jcode" for a similar method not defined error with each_byte. I tried adding that but...

PHP string to object name.

Ok I have a string... $a_string = "Product"; and I want to use this string in a call to a object like this: $this->$a_string->some_function(); How the dickens do I dynamically call that object? (don't think Im on php 5 mind) ...

Probelm with String.split() in java

What I am trying to do is read a .java file, and pick out all of the identifiers and store them in a list. My problem is with the .split() method. If you run this code the way it is, you will get ArrayOutOfBounds, but if you change the delimiter from "." to anything else, the code works. But I need to lines parsed by "." so is there a...

PHP preg_match, need some help

Can someone please help me with this preg_match if (preg_match('~[^A-Za-z0-9_\./\]~', $filepath)) // Show Error message. I need to match a possible filepath. So I need to check for double slashes, etc. Valid file path strings should look like this only: mydir/aFile.php or mydir/another_dir/anyfile.js So a slash at the begi...

How to turn such string into a data grid? (C# .Net)

So I have such string (recived from php server... normal print_r of array) Array ( [item_number_in_array] => Array ( [id] => id_value [title] title_value_as_string_vith_spaces [content] => content_value_as_string_vith_spaces ) [item_number_in_array]... ) I need any how to represent it as table like this in C# How to do such thi...

References to other strings in strings.xml ?

Hi Is it possible to reference other strings inside of strings.xml ? Something of the form: <string name="string_one">My string</string> <string name="string_two">Here it is: android:id="@string/string_one" </string> (If it did exist, there would of course be problems of circular, infinite definitions, etc. to beware of). Thanks. ...

Find a part of UNC path and put in a variable?

I am trying to peel off the last part of a unc path that is being passed and put it in a variable to use in a method further down the line. Example path would be --> \\ourfileserver\remoteuploads\countyfoldername\personfoldername How do I peel just the countyfoldername out of that? I had thought to try var th = e.FullPath.LastIndexO...

Conversion of byte[] into a String and then back to a byte[]

I am working on a proxy server. I am getting data in byte[] which I convert into a String to perform certain operations. Now when i convert this new String back into a byte[] it causes unknown problems. So mainly its like I need to know how to correctly convert abyte[] into a String and then back into a byte[] again. I tried to just co...

multibyte strtr() -> mb_strtr()

Does anyone have written multibyte variant of function strtr() ? I need this one. Edit 1 (example of desired usage): Example: $from = 'ľľščťžýáíŕďňäô'; // these chars are in UTF-8 $to = 'llsctzyaiŕdnao'; // input - in UTF-8 $str = 'Kŕdeľ ďatľov učí koňa žrať kôru.'; $str = mb_strtr( $str, $from, $to ); // output - str without di...

How to find string elements in another string and remove them in PHP

By example: FirstString='apple,gold,nature,grass,class' SecondString='gold,class' the Result must be : ResultString='apple,nature,grass' ...

How to prepare Cyrilic and other variables for storing into MySql DB? (PHP)

How to prepare Cyrilic and other variables for storing into MySql DB? (PHP) So I need realy simple way to prepare recived from browser $_GET[string] variables for storing into DB. How to do such thing? ...

preg_replace, exact opposite of a preg_match

I need to do a preg_replace for the exact opposite of this preg_match regular expression: preg_match('#^(\w+/){0,2}\w+\.\w+$#', $string); So I need to replace all strings that are not valid with an empty string -> '' So it needs to remove the first / and last / if found, and all non-valid characters, that is the only valid characters...

How to turn string into readable by php server way? (С#)

So I know that my server on real form submit turns %CE%EB%E5%E3+%DF%EA%F3%F8%EA%E8%ED into Олег Якушкин . How to peform string transfer from Олег Якушкин into %CE%EB%E5%E3+%DF%EA%F3%F8%EA%E8%ED using C#? ...

Rookie PHP question

I am hacking together a theme for wordpress and I am using the following code to pull out data from a custom field with several values: <?php $mykey_values = get_post_custom_values('services'); foreach ( $mykey_values as $key => $value ) { echo "<span>$value, </span>"; } ?> I use a comm...

String Parsing in C#

What is the most efficient way to parse a C# string in the form of "(params (abc 1.3)(sdc 2.0)(www 3.05)....)" into a struct in the form struct Params { double abc,sdc,www....; } Thanks EDIT The structure always have the same parameters (same names,only doubles, known at compile time).. but the order is not granted.. only one s...

Third-party titlecase method in Python

The standard string title() method in Python is pretty naive and doesn't correctly handle converting even fairly simple words and phrases to title case (hyphenated words, phrases with quotes, phrases with prepositions, etc.). In Googling around, I found a few solutions in different languages to this problem. Can anyone recommend a good ...

How to parse a string of boolean logic in PHP

I'm building a PHP class with a private member function that returns a string value such as: 'true && true || false' to a public member function. (This string is the result of some regex matching and property lookups.) What I'd like to do is have PHP parse the returned logic and have the aforementioned public function return whether...

C# Extension Method for String Data Type

My web application deals with strings that need to be converted to numbers alot - users often put commas, units (like cm, m, g, kg) and currency symbols in these fields so what I want to do is create a string extension method that cleans the field up and converts it to a decimal. For example: decimal myNumber = "15 cm".ToDecimal(); ...