substitution

How do I avoid repetition in Java ResourceBundle strings?

对着背影说爱祢 提交于 2019-12-03 02:04:31
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 amount of text our translator has to translate. The solution I came up with went something like this: public class ExpandingResourceBundleControl extends ResourceBundle.Control { public static final ResourceBundle.Control EXPANDING = new

Combining multiple bash parameter substitutions within same variable set line without using any other commands [closed]

帅比萌擦擦* 提交于 2019-12-03 01:21:58
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . Example of what I want to combine: sVar=$(whoami) sVar=${sVar^} sVar=${sVar::1} Output: Uppercase first character of username Requirements: One-liner Do the rest of the processing with parameter substitutions except for the initial command substitution above $(whoami) I realize

Creating expression tree in R

自作多情 提交于 2019-12-02 20:57:09
The substitute function in R creates a language object in the form of a tree that one can parse. How can I create the tree from scratch using list or else to then give it to eval? # substitute gives a tree representation of the expression a=1; b=2; e1 = substitute(a+2*b) eval(e1) #gives 5 as expected e1 # is type language e1[[1]] # this is `+` e1[[2]] # this is 'a' type symbol e1[[3]] # this is type language e1[[3]][[1]] # this is `*` etc.... I would like to know how I can reconstruct the e1 object programmatically. Ideally I create an object of intricated lists with the correct object in them

VIM, Run a command on multiple files

痴心易碎 提交于 2019-12-02 20:41:03
I have a bunch of sass files and my designer used the wrong syntax. I wanted :margin-top 1px but he did margin-top: 1px So I easily wrote a sub command: :rubydo sub! /([\w-]+):/,':\1' So that works and fixes all the colons and moves them in the place I want. I have about 50 sass files in a stylesheets directory. How can I run this command on all my files in one shot? I'm not really sure how to go about this in vim . Maybe something to do with grep ? I couldn't tell ya. See this: http://vimdoc.sourceforge.net/htmldoc/editing.html#:argdo I learned this command right now, but the help is clear.

How to substitute a paragraph in file?

假装没事ソ 提交于 2019-12-02 14:41:12
问题 I want to change more than a line of a file. It is a CSS file and I want to swap out a section to another. This is a snippet from the file: /*** Debugging ***/ draw-button-bounding-rects: false; draw-button-rects: false; debug-touch-points: false; draw-reactive-areas: false; } MImAbstractKeyAreaStyle.Landscape { /*** Label Setttings ***/ label-margin-top: 0.6mm; label-margin-left-with-secondary: -1; /* not used, labels are centered horizontally */ secondary-label-separation: 0; /*** Behaviour

Perl hash substitution with special characters in keys

爱⌒轻易说出口 提交于 2019-12-02 13:58:54
My current script will take an expression, ex: my $expression = '( a || b || c )'; and go through each boolean combination of inputs using sub/replace, like so: my $keys = join '|', keys %stimhash; $expression =~ s/($keys)\b/$stimhash{$1}/g; So for example expression may hold, ( 0 || 1 || 0 ) This works great. However, I would like to allow the variables (also in %stimhash) to contain a tag, *. my $expression = '( a* || b* || c* )'; Also, printing the keys of the stimhash returns: a*|b*|c* It is not properly substituting/replacing with the extra special character, *. It gives this warning: Use

Combining multiple bash parameter substitutions within same variable set line without using any other commands [closed]

本小妞迷上赌 提交于 2019-12-02 13:41:55
Example of what I want to combine: sVar=$(whoami) sVar=${sVar^} sVar=${sVar::1} Output: Uppercase first character of username Requirements: One-liner Do the rest of the processing with parameter substitutions except for the initial command substitution above $(whoami) I realize this can be done with tr, sed, awk, printf, cut, etc.; but that is not the point of the question. Any help is appreciate! This isn't the real code or anything indicative of what I am wanting to actually do. I will often default (or try to) to using just one command over concatenating multiple commands. I've seen other

How to substitute a paragraph in file?

瘦欲@ 提交于 2019-12-02 10:20:09
I want to change more than a line of a file. It is a CSS file and I want to swap out a section to another. This is a snippet from the file: /*** Debugging ***/ draw-button-bounding-rects: false; draw-button-rects: false; debug-touch-points: false; draw-reactive-areas: false; } MImAbstractKeyAreaStyle.Landscape { /*** Label Setttings ***/ label-margin-top: 0.6mm; label-margin-left-with-secondary: -1; /* not used, labels are centered horizontally */ secondary-label-separation: 0; /*** Behaviour ***/ touchpoint-horizontal-gravity: 32px; touchpoint-vertical-gravity: 20px; /*** Key Geometry ***/

Prolog substitution

做~自己de王妃 提交于 2019-12-02 07:25:49
问题 How can I replace a list with another list that contain the variable to be replaced. for example rep([x, d, e, z, x, z, p], [x=z, z=x, d=c], R). R = [z, c, e, x, z, x, p] the x to z and z doesn't change after it has been replaced. so far I did only the one without the list rep([], _, []). rep(L1, H1=H2, L2) :- rep(L1, H1, H2, L2). rep([],_,_,[]). rep([H|T], X1, X2, [X2|L]) :- H=X1, rep(T,X1,X2,L), !. rep([H|T],X1,X2,[H|L]) :- rep(T,X1,X2,L). 回答1: I find your code rather confused. For one

How to preserve spaces when outputting a shell variable? [duplicate]

独自空忆成欢 提交于 2019-12-02 04:16:25
This question already has an answer here: I just assigned a variable, but echo $variable shows something else 6 answers For string matching purposes I need to define a bash variable with leading spaces. I need to define this starting from an integer, like: jj=5 printf seems to me a good idea, so if I want to fill spaces up to 6 character: jpat=`printf " %6i" $jj` but unluckly when I am trying to recall the variable: echo $jpat the leading whitespaces are removed and I only get the $jj integer as it was. Any solution to keep such spaces? (This is equivalent to this: v=' val'; echo $v$v . Why