string

Are there particular cases where native text manipulation is more desirable than regex?

Are there particular cases where native text manipulation is more desirable than regex? In particular .net? Note: Regex appears to be a highly emotive subject, so I am wary of asking such a question. This question is not inviting personal/profession opinions on regex, only specific situations where a solution including its use is not as...

Emitting a colon via format string in .NET

Does anyone know how to construct a format string in .NET so that the resulting string contains a colon? In detail, I have a value, say 200, that I need to format as a ratio, i.e. "1:200". So I'm constructing a format string like this "1:{0:N0}" which works fine. The problem is I want zero to display as "0", not "1:0", so my format stri...

Why is the beginning of my string disappearing?

In the following C++ code, I realised that gcount() was returning a larger number than I wanted, because getline() consumes the final newline character but doesn't send it to the input stream. What I still don't understand is the program's output, though. For input "Test\n", why do I get " est\n"? How come my mistake affects the first...

Problem with Strpos In PHP

Hey Folks I'm writing a simple function and for some reason(probably a simple one) it's not working for me and I was wondering if you guys could help me out. function check_value($postID) { $ID = $postID; $cookie = $_COOKIE['list_of_IDS']; $position = strpos($cookie,$ID); echo 'ID:'.$ID.'-Cookie:'.$cookie; ...

AnsiString return values from a Delphi 2007 DLL in a Delphi 2009 application

I have a DLL compiled with D2007 that has functions that return AnsiStrings. My application is compiled in D2009. When it calls the AnsiString functions, it gets back garbage. I created a little test app/dll to experiment and discovered that if both app and dll are compiled with the same version of Delphi (either 2007 or 2009), there i...

Context-sensitive string splitting, preserving delimiters

I have a string of the form "foo-bar-1.23-4", and I need to split at the first hypen followed by a numeral, such that the result is ['foo-bar', '1.23-4']. I've tried the following: >>> re.split('-\d', 'foo-bar-1.23-4', 1) ['foo-bar', '.23-4'] and >>> re.split('-(\d)', 'foo-bar-1.23-4', 1) ['foo-bar', '1', '.23-4'] with suboptimal r...

ASP.NET - Users have direct control on a Label control: this is safe?

I made a page where something entered in a TextBox, is displayed "as-is" on a Label control Since i am a beginner, I just made: Label1.Text = TextBox1.Text.ToLower(); Is this dangerous? I tried something but it seems that Label controls only takes text, i i felt confident that is safe Maybe is dangerous if the user will insert some ...

Splitting a string @ once using different seps

datetime = '0000-00-00 00:00:00'.split('-') Right now it just splits it at the hyphen, but is it possible to split this string at both -'s and :'s ? ...

writing directly to std::string internal buffers

I was looking for a way to stuff some data into a string across a DLL boundary. Because we use different compilers, all our dll interfaces are simple char*. Is there a correct way to pass a pointer into the dll function such that it is able to fill the string buffer directly? string stringToFillIn(100, '\0'); FunctionInDLL( stringToFi...

Get numbers from string with regex

Hi, I am trying to write a regex to get the numbers from strings like these ones: javascript:ShowPage('6009',null,null,null,null,null,null,null) javascript:BlockLink('2146',null,null,null) I am having difficulty writing the regex to grab these numbers. Could anyone lend a hand? Cheers Eef ...

Algorithms to recognize misspelled names in texts

I need to develop an application that will index several texts and I need to search for people’s names inside these texts. The problem is that, while a person’s correct name is “Gregory Jackson Junior”, inside the text, the name might me written as: - Greg Jackson Jr - Gegory Jackson Jr - Gregory Jackson - Gregory J. Junior I plan t...

'#' character before EL expression used inside a JSTL tag behaves strangely

I have the following code to set a userId variable: (userId set in prior code) <c:set var="userId" value="(Cust#${userId})" /> Which produces the following string: (Cust#${userId}) The following code works as expected, however: <c:set var="userId" value="(Cust# ${userId})" /> displays the following string (Cust# 0001) . Why does...

filename.Contains #(pound) or ' (single quote)

In c# how can I check in the file name has the "pound sign" and "apostrophe sign" This is waht I tried so far but doesn't work. I need to send an error if the # or ' are in the filename return filename.Contains("#\'"); ...

PHP - Function to skip strtolower() if variable contain "wikipedia.org"

Hello, My site allows users to enter URLs into a database. I am using the code "$site = strtolower($site);" to make all of these URLs lower-case. However, I just realized that Wikipedia URLs are case sensitive, so I would like to avoid using "$site = strtolower($site);" on Wikipedia URLs, all of which contain "wikipedia.org". How co...

in Ruby, trying to convert those weird quotes into "regular" quotes

I am trying to parse a text file that has the weird quotes like “ and ” into "normal quotes like " I tried this: text.gsub!("“",'"') text.gsub!("”",'"') but when it's done, they are still there and show up as \x93 and \x94 so I tried adding that too with no luck: text.gsub!('\\x93', '"') text.gsub!('\\x94', '"') The problem is,...

Session StateServer connection string issue

We implemented the session state server and deployed in local PC(windows xp) its working fine. WE deployed in windows server 2003 we got the issue in connection string. Any one help me. ...

Format a double value like currency but without the currency sign (C#)

Hi, I feed a textbox a string value showing me a balance that need to be formatted like this: ###,###,###,##0.00 I could use the value.ToString("c"), but this would put the currency sign in front of it. Any idea how I would manipulate the string before feeding teh textbox to achieve the above formatting? I tried this, without succe...

How to change the format of specified lines in a RichTextBox

I have a winforms RichTextBox containing lots of lines of text (eg 2 MB text files), and would like to programmatically change the formatting of specified lines, eg highlighting them. How can I address the lines, rather than the characters? Is a RichTextBox even the best control for this sort of thing, or is there another alternative? I...

CharSequence VS String in Java ?

Programming in Android, most of the text values are expected in CharSequence. Why is that ? What is the benefit and what are the main impacts of using CharSequence over String ? What are the main differences, and what issues are expected, while using them, and converting from one to another ? ...

Using Map on a list of tuples and print it as flat string in Erlang

I have a list of tuples: X = [{"alpha","beta"},{"gamma","theta"}]. I want to print X as a flat string using, io_lib:format("~s", [X]) in the following format: [{"x":"alpha", "y":"beta"}, {"x":"gamma", "y":"theta"}] How do I achieve this? I started using Map to do transform the list. But I was not able to print it as a string...(ga...