string-manipulation

advanced string management and completion C#

Hello, Alright, so im going to jump in with my situation: so i have string[] MyStringArray with "hello", "goodbye", "morning" in it, and now i have a normal string MatchString = "hel", now, on a specific trigger, id like to be able to loop through the strings in MyStringArray, and find the most likely match, and replace. so for instanc...

Using C, convert a dynamically-allocated int array to a comma-separated string as cleanly as possible

I’m much less experienced in C than I am in higher-level languages. At Cisco, we use C, and I sometimes run into something that would be easy to do in Java or Python, but very difficult to do in C. Now is one of those times. I have a dynamically-allocated array of unsigned integers which I need to convert to a comma-separated string for...

how do I replace all the links in a text using regex in as3 ?

Hello, I am using a regular expression to find links in a generic string and highlight that text(underline, a href, anything). Here's what I have so far: var linkRegEx:RegExp = new RegExp("(https?://)?(www\\.)?([a-zA-Z0-9_%]*)\\b\\.[a-z]{2,4}(\\.[a-z]{2})?((/[a-zA-Z0-9_%]*)+)?(\\.[a-z]*)?(:\\d{1,5})?","g"); var link:String = 'generic ...

Building a reverse language dictionary

I was wondering what does it take to build a reverse language dictionary. The user enters something along the lines of: "red edible fruit" and the application would return: "tomatoes, strawberries, ..." I assume these results should be based on some form of keywords such as synonyms, or some form of string search. This is an online ...

Python equivalent of ruby's StringScanner?

Is there a python class equivalent to ruby's StringScanner class? I Could hack something together, but i don't want to reinvent the wheel if this already exists. ...

Using string.Substring() as part of a chain

Hi guys I'm trying to maniplulate a string without making a big issue out of it and spreading it out onto multiple lines, so I'm using some chaining to achieve this. The question I have is, how do I use string.Substring() to drop the last character off my string in this context? In PHP I can pass a negative number as an argument (i.e. ...

How to check if there are only spaces in string in PHP?

print_r(strlen(trim(' '))); the result is 9 I also tried preg_replace('/[\n\r\t\s]/', '', ' ') but the result is not zero. Please download my code and you will get the result http://blog.eood.cn/attachment.php?id=70 ...

php find some text in a string (if it's there)

Hi All, I have a MYSQL database of photo galleries; each row contains a field with the list of images included in that gallery, eg: 1,5,134,13,5 these are the IDs of the photos. The same image_id could be included in other galleries. When I delete a photo, I need to remove the corresponding id from the galleries that contain it. Wha...

Regular Expressions and php

I have a form where users enter a URL. I need a regular expression to skip the part 'http://' if present. For example, if the user insert into the form: http://youtube.com I need to save only youtube.com. I don't know regular expressions. Could you help me? Thanks! ...

How to efficiently concatenate strings in Go?

In Go, string is a primitive type, it's readonly, every manipulation to it will create a new string. So, if I want to concatenate strings many times without knowing the length of the resulting string, what's the best way to do it? The naive way would be: s := ""; for i := 0; i < 1000; i++ { s += getShortStringFromSomewhere(); } r...

Extract part of string in flash

Hi all, I have this string <p><img src="http://www.foo.com/bar.jpg"&gt;&lt;/p&gt;&lt;p&gt;other content here</p> I need to extract the src url . The img tag appears only at the beggining of the string. Thanks in advance. ...

C++ String manipulation - if stament

I have the following code that works correctly. However after I add an else statement anything always evaluates to else wgetstr(inputWin, ch); //get line and store in ch variable str = ch; //make input from char* to string if(str=="m" || str=="M"){ showFeedback("Data Memory Updated"); } if(str=="p" || ...

How To Change List of Chars To String?

In F# I want to transform a list of chars into a string. Consider the following code: let lChars = ['a';'b';'c'] If I simply do lChars.ToString, I get "['a';'b';'c']". I'm trying to get "abc". I realize I could probably do a List.reduce to get the effect I'm looking for but it seems like there should be some primitive built into th...

C++ convert int and string to char*

This is a little hard I can't figure it out. I have an int and a string that I need to store it as a char*, the int must be in hex i.e. int a = 31; string str = "a number"; I need to put both separate by a tab into a char*. Output should be like this: 1F a number ...

string-split in DrScheme

How do I do equivalent of python's str.split in DrScheme? SRFI-13 doesn't seem to have it provided. ...

Turn a string into a regexp that matches the plain string, in DrScheme

I want to split a string based on a non-regular expression. My input is a plain string. So, for example, given the input "hello.*there" and ".*", I want the result ("hello" "there"). Doing this obv doesn't work: (regexp-split (regexp sep) str)) since it will try to match the regular expression .*. How do I escape sep to nullify any r...

Remove specified text from beginning of lines only if present (C#)

I have a textbox in which the user can edit text, in a scripting language. I've figured out how to let the user comment out lines in one click, but can't seem to figure out how to uncomment properly. For example, if the box has: Normal Text is here More normal text -- Commented text -- More commented text Normal Text again --Commented ...

boost to_upper function of string_algo doesn't take into account the locale

I have a problem with the functions in the string_algo package. Consider this piece of code: #include <boost/algorithm/string.hpp> int main() { try{ string s = "meißen"; locale l("de_DE.UTF-8"); to_upper(s, l); cout << s << endl; catch(std::runtime_error& e){ cerr << e.what() << endl; } try{ ...

Need help with RegEx for ranges

I want to be able to use a RegEx to parse out ranges like a Windows Print dialog (such as 1-50,100-110,111,112). The following is my current code and I am not clear on how to parse for the additional commas and numbers. I can parse out the hyphen, but not sure how to do it for additional commas or hyphens private void tboxRowNum_Leave(o...

How can I insert a character after every n characters in javascript?

I have a string: "The quick brown fox jumps over the lazy dogs." I want to use javascript (possibly with jQuery) to insert a character every n characters. For example I want to call: var s = "The quick brown fox jumps over the lazy dogs."; var new_s = UpdateString("$",5); // new_s should equal "The q$uick $brown$ fox $jumps$ over$ the...