replacement

PowerShell - how do I do a string replacement in a function?

How do I convert function input parameters to the right type? I want to return a string that has part of the URL passed into it removed. This works but uses a hard coded string: function CleanUrl($input) { $x = "http://google.com".Replace("http://", "") return $x } $SiteName = CleanUrl($HostHeader) echo $SiteName This fails:...

How do I perform a Perl substitution on a string while keeping the original?

In Perl, what is a good way to perform a replacement on a string using a regular expression and store the value in a different variable, without changing the original? I usually just copy the string to a new variable then bind it to the s/// regex that does the replacement on the new string, but I was wondering if there is a better way ...

Any Substitute API for Win32API?

Hello, I need an API that can make menus like Win32API, But something simpler and better than WinAPI. That can make GUI, with text zones, buttons etc...like an average Windows program.(Windows GUI Style) Can anyone recommand on one like it? Thanks. ...

Has anyone tried their software with ReactOS yet?

The Free MS Windows replacement operating system ReactOS has just released a new version. They have a large and active development team. Have you tried your software with it yet? if so what is your recommendation? Is it time to start investigating it as a serious Windows replacement? ...

Java Regular Expressions Replacement

Just could not get this one and googling did not help much either.. First something that I know: Given a string and a regex, how to replace all the occurrences of strings that matches this regular expression by a replacement string ? Use the replaceAll() method in the String class. Now something that I am unable to do. The regex I hav...

Replacing a word with another word zero or more times in javascript using regular expressions

I have a word : [lesserthen] , that I need to replace with < zero or more times in a string. I'm using the String.replace method to do so. But the word is only replaced one time in the string, I need to be replaced more then one time. I'm very weak with regular expressions and I'm interested to find a solution for this problem. Here i...

Efficient Javascript String Replacement

Hey there, I've got a block of HTML that I'm going to be using repeatedly (at various times during a users visit, not at once). I think that the best way to accomplish this is to create an HTML div, hide it, and when needed take its innerHTML and do a replace() on several keywords. As an example HTML block... <div id='sample'> <h4>%...

The replacement to the name attribute...

I am confused. I need to name my iframe in order to use the name as the target in my menu's hypelinks. According to my Visual Web Developer Express the name attribute is considered outdated and a new construct is required. My question is what attrbute code do I utilize to name my iframe. Thank you ...

How can I replace all the HTML-encoded accents in Perl?

I have the following situation: There is a tool that gets an XSLT from a web interface and embeds the XSLT in an XML file (Someone should have been fired). "Unfortunately" I work in a French speaking country and therefore the XSLT has a number of words with accents. When the XSLT is embedded in the XML, the tool converts all the accents...

replacing regex in java string, which contains `&#xA;` symbol

I have to replace the content of this xml string through java <My:tag>value_1 22&#xA;value_2 54&#xA;value_3 11</My:tag> so, this string has been taken from an xml and when I acquire it I have this result: <My:tag>value_1 22 value_2 54 value_3 11</My:tag> If I try to replace the content by this way: String regex = "(<My:tag>)(.*)(...

Automatically replacing variables with #defines

Hi guys, I've got a tricky problem that I need some help with. Currently, I have a file with about 100 #defines in it, from 1-100, and each with a unique string value. Now I'm trying to print this value, but instead of the value, I want to print what the #define is. For example: #define FIRST_VALUE 1 var = FIRST_VALUE; printf("%s", va...

Removing nonnumeric and nonalpha characters from a string?

What is the best way to remove all the special characters from a string - like these: !@#$%^&*(){}|:"?><,./;'[]\=- The items having these characters removed would rather short, so would it be better to use REGEX on each or just use string manipulation? Thx Environment == C#/.NET ...

Programming Language Reference: String Replacement

I am seeing if it's worthwhile creating a reference showing how to do common things in multiple programming languages. Please list below the command that you would use to achieve the following in your chosen programming language: String Replacement examples: PHP: mixed str_replace ( mixed $search , mixed $replace , mixed $subject [,...

Replacing String Columnwise Using Sed

Given this data 34 foo 34 bar 34 qux 62 foo1 62 qux 78 qux I want to replace the string at 2nd column into "" if it is "qux". Resulting: 34 foo 34 bar 34 62 foo1 62 78 How do you do that with sed? In particular the data is very big with ~10^7 lines ...

Replace multiple characters in a string in Objective-C?

In PHP I can do this: $new = str_replace(array('/', ':', '.'), '', $new); ...to replace all instances of the characters / : . with a blank string (to remove them) Can I do this easily in Objective-C? Or do I have to roll my own? Currently I am doing multiple calls to stringByReplacingOccurrencesOfString: strNew = [strNew stringByRe...

String manipulation in Python

I am converting some code from another language to python. That code reads a rather large file into a string and then manipulates it by array indexing like: str[i] = 'e' This does not work directly in python due to the strings being immutable. What is the preferred way of doing this in python ? I have seen the string.replace() functi...

Perform a lot of replacements in a text file using a huge list of replacement pairs

Given: file a.txt containing many millions of lines (say, one sentence per line) (2.6 gb!) file b.txt containing 830k lines with pairs "[word1] [word2]" Question: how to perform the most efficient replacement of each word1 by word2 for every of 830k tuples (w1, w2) in the huge text file? Naive methods like sed, perl, python etc. wo...

C/C++ replacement/redefinition rules?

I am not particularly new to C/C++ but today I discovered some things that I didn't expect. This compiles in gcc: /* test.c */ #include <stddef.h> // ! typedef unsigned long int size_t; // NO ERROR typedef unsigned long int size_t; // NO ERROR int main(void) { typedef unsigned long int size_t; // NO ERROR return 0; } This doesn...

Replace umlaute (äüö) for SEO link in rails - best way

Hi, I'm using the permalink_fu plugin to create permalinks from titles. My problem is: If the title contains german characters, they are just replaced with '_'. What I need is something that replaces ä with ae ü with ue ö with oe I fount String.tr but the problem here is that it replaces 1 character with 1 replacement, so it would wor...

How can I replace a specific word in C#?

Consider the following example. string s = "The man is old. Them is not bad."; If I use s = s.Replace("The", "@@"); Then it returns "@@ man is old. @@m is not bad." But I want the output to be "@@ man is old. Them is not bad." How can I do this? ...