substitution

Getting Short-Filename of Command-Line Argument from Batch-File

Hi, The following command in a batch file does not work as expected/hoped:     echo %~nxs1 Here is a sample display of what I’m trying to get: C:\>type test.bat @dir /b %1 @echo %~nxs1 C:\>test "C:\Documents and Settings\All Users\ntuser.dat" ntuser.dat NTUSER.DAT C:\>test "C:\Documents and Settings\All Users\ntuser.data" ntuser.d...

Is there an Icacls funtion similar to /replace in subinacl?

My company has been utilizing the subinacl tool to fix SIDs that change unexpectedly. We are now switching over to Windows 7 and the subinacl tool is no longer utilized. I am trying to find the code equivalents of the subinacl funtions for Icacls and so far the only one I have been unable to find has been /replace. The /substitute functi...

how do I use c preprocessor to make a substitution with an environment variable

In the code below, I would like the value of THE_VERSION_STRING to be taken from the value of the environment variable MY_VERSION at compile time namespace myPluginStrings { const char* pluginVendor = "me"; const char* pluginRequires = THE_VERSION_STRING; }; So that if I type: export MY_VERSION="2010.4" pluginRequires will be se...

how can I force C++ macro substitution at the time I choose in this case?

I couldn't think of a better way to word the title... #define X(c) c #define Y(c) X(c) #undef X int main(int argc,char*argv[]) { std::cout << Y(5) << std::endl; return 0; } This causes an error, because X() is not declared in this scope. Is there any way to make Y store a copy of X (aka, force the macro substitution to occur...

Using C# to detect whether a filename character is considered international

I've written a small console application (source below) to locate and optionally rename files containing international characters, as they are a source of constant pain with most source control systems (some background on this below). The code I'm using has a simple dictionary with characters to look for and replace (and nukes every othe...

ASP.NET MVC 1.0: OutputCache, RenderPartial and WriteSubstitution

Hi folks, after digging into this topic and having the requirement, that a single page should be totally cached, except for a Html.RenderPartial("LogOnUserControl"); i couldn't find any working solution on this... the only "its getting warmer" solution i found was this one , which unfortunately is not working with a "partial view", ...

Weird behavior of substitution in Mathematica.

My question is: why doesn't the following work, and how do I fix it? Plot[f[t], {t, 0, 2*Pi}] /. {{f -> Sin}, {f -> Cos}} The result is two blank graphs. By comparison, DummyFunction[f[t], {t, 0, 2*Pi}] /. {{f -> Sin}, {f -> Cos}} gives {DummyFunction[Sin[t], {t, 0, 2 *Pi}], DummyFunction[Cos[t], {t, 0, 2 * Pi}]} as desired. ...

How can I substitute the nth occurrence of a match in a Perl regex?

Following up from an earlier question on extracting the n'th regex match, I now need to substitute the match, if found. I thought that I could define the extraction subroutine and call it in the substitution with the /e modifier. I was obviously wrong (admittedly, I had an XY problem). use strict; use warnings; sub extract_quoted { # ...

Is there a Perl idiom which is the functional equivalent of calling a subroutine from within the substitution operator?

Perl allows ... $a = "fee"; $result = 1 + f($a) ; # invokes f with the argument $a but disallows, or rather doesn't do what I want ... s/((fee)|(fie)|(foe)|(foo))/f($1)/ ; # does not invoke f with the argument $1 The desired-end-result is a way to effect a substitution geared off what the regex matched. Do I have to write sub lal...

How do I avoid repetition in Java ResourceBundle strings?

We had a lot of strings which contained the same sub-string, from sentences about checking the log or how to contact support, to branding-like strings containing the company or product name. The repetition was causing a few issues for ourselves (primarily typos or copy/paste errors) but it also causes issues in that it increases the amo...

Why is my asp:Substitution control suddenly not working in ASP.NET 4.0?

I just upgraded my site from ASP.NET 3.5 to 4.0. I've been working through some breaking changes and there were more than I expected. One I can't figure out, however, is why my <asp:Substitution /> control suddenly stopped working like it should. It's supposed to ignore the output cache settings of the parent page and update upon ev...

How can I use Perl's s/// in an expression?

I got a headache looking for this: How do you use s/// in an expression as opposed to an assignment. To clarify what I mean, I'm looking for a perl equivalent of python's re.sub(...) when used in the following context: newstring = re.sub('ab', 'cd', oldstring) The only way I know how to do this in perl so far is: $oldstring =~ s/ab/c...

What's a good way to parameterize "static" content (e.g. CSS) in a Tomcat webapp?

Some of our CSS files contain parameters that can vary based on the deployment location (dev, QA, prod). For example: background: url(#DOJO_PATH#/dijit/themes...) to avoid hardcoding a path to a particular CDN or locally-hosted Dojo installation. These values are textually substituted with the real values by a deployment script, whe...

Perl Substitution

hi, I have a variable which stores the path on Windows. I want to replace all the \ with / in the path. for eg. $path = C:\Users\scripts.ps1 Am new to Perl and tried something like $path = s/\\//// But it didnt work. can you please help me out.... ...

How do I perform multiple replacements with Perl?

I have Perl code: my $s = "The+quick+brown+fox+jumps+over+the+lazy+dog+that+is+my+dog"; I want to replace every + with space and dog with cat. I have this regular expression: $s =~ s/\+(.*)dog/ ${1}cat/g; But, it only matches the first occurrence of + and last dog. ...

Maven: properties not being substituted

I'm using a maven plugin for install4j in my project, located here. That plugin lets you pass variables to install4j using the <compilerVariables> section. Here's the relevant section of my pom: <plugin> <groupId>com.google.code.maven-install4j</groupId> <artifactId>maven-install4j-plugin</artifactId> <version>0.1.1</version...

substitution cypher with different alphabet length

I would like to implement a simple substitution cypher to mask private ids in URLs I know how my IDs will look like (combination of upperchase ascii, digits and underscore), and they will be rather long, as they are composed keys. I would like to use a longer alphabet to shorten the resulting codes (I'd like to use upper and lower case ...

What is wrong with this substitution?

#!/usr/bin/perl use strict; use warnings; my $s = "sad day Good day May be Bad Day "; $s =~ s/\w+ \w+/_/gm; print $s; I am trying to substitute all spaces between words with _, but it is not working. What is wrong with that? ...

Recursive multiline sed - remove beginning of file until pattern match.

I have nested subdirectories containing html files. For each of these html files I want to delete from the top of the file until the pattern <div id="left- This is my attempt from osx's terminal: find . -name "*.html" -exec sed "s/.*?<div id=\"left-col/<div id=\"left-col/g" '{}' \; I get a lot of html output in the termainal, but no f...

How to export the matches only in a pattern search in vim?

Is there a way to grab and export the match part only in a pattern search without changing the current file? For example, from a file containing: 57","0","37","","http://www.thisamericanlife.org/Radio_Episode.aspx?episode=175" 58","0","37","","http://www.thisamericanlife.org/Radio_Episode.aspx?episode=170" I want to export a new fil...