substitution

How can I combine multiple nested Substitute functions in Excel?

瘦欲@ 提交于 2019-12-04 02:52:11
问题 I am trying to set up a function to reformat a string that will later be concatenated. An example string would look like this: Standard_H2_W1_Launch_123x456_S_40K_AB Though sometimes the " S " doesn't exist, and sometimes the "40K" is "60K" or not there, and the "_AB" can also be "_CD" or _"EF". Finally, all underscores need to be changed to hyphens. The final product should look like this: Standard-H2-W1-Launch-123x456- I have four functions that if ran one after the other will take care of

How do I substitute with an evaluated expression in Perl?

我与影子孤独终老i 提交于 2019-12-04 01:58:23
There's a file dummy.txt The contents are: 9/0/2010 9/2/2010 10/11/2010 I have to change the month portion (0,2,11) to +1, ie, (1,3,12) I wrote the substitution regex as follows $line =~ s/\/(\d+)\//\/\1+1\//; It's is printing 9/0+1/2010 9/2+1/2010 10/11+1/2010 How to make it add - 3 numerically than perform string concat? 2+1 ?? Three changes: You'll have to use the e modifier to allow an expression in the replacement part. To make the replacement globally you should use the g modifier. This is not needed if you've one date per line. You use $1 on the replacement side, not a backreference

In VIM, is it possible to use the selected text in the substitute clause without retyping it?

断了今生、忘了曾经 提交于 2019-12-03 16:51:34
问题 Let's say I have a word selected in visual mode. I would like to perform a substitution on that word and all other instances of that word in a file by using s//. Is there a way to use the highlighted text in the s/<here>/stuff/ part without having to retype it? 回答1: Sure. If you selected the word, just "y"ank it, and then type: :%s/<ctrl-r>"/something else/g Where is pressing ctrl key with r key, and " is just " character. All keypresses: y:%s/<ctrl-r>"/what to put/g<enter> 回答2: If you

Getting the parse tree for a predefined function in R

痞子三分冷 提交于 2019-12-03 15:38:11
I feel as if this is a fairly basic question, but I can't figure it out. If I define a function in R, how do I later use the name of the function to get its parse tree. I can't just use substitute as that will just return the parse tree of its argument, in this case just the function name. For example, > f <- function(x){ x^2 } > substitute(f) f How should I access the parse tree of the function using its name? For example, how would I get the value of substitute(function(x){ x^2 }) without explicitly writing out the whole function? I'm not exactly sure which of these meets your desires: eval

How can I make SQL Developer/SQL+ prompt only once for a substitution variable that occurs multiple times in a single statement?

我的未来我决定 提交于 2019-12-03 15:16:46
I have a query roughly like this: select * from A_TABLE where A_COLUMN = '&aVariable' union select * from A_TABLE where B_COLUMN = '&aVariable'; But when I run it, SQL Developer prompts me for the variable twice, even though it's the same variable. If there's a way to make it prompt only once for a variable that is used twice, how do I do it? I do not want to use a script, it must be a single executable query. As I was forming this post, I figured out how to do it: :a_var select * from A_TABLE where A_COLUMN = :a_var union select * from A_TABLE where B_COLUMN = :a_var; SQL Developer will then

Prepend file names with plus sign

假如想象 提交于 2019-12-03 14:39:47
I want to add a + (plus sign) before all the occurrences of image names in a huge file, using sed . This is an example of one line: DAUSSI-H22-14K White Gold-Princess-1.00ct-G-SI1orH-VS2-EGL-mm-3.5,,H22,,7050,5720,3/5/2012 7:34,,,1,,henri-daussi-h22-diamond-halo-engagement-ring-14k-white-gold-width--mm-style-princess-1-00ct-g-si1-or-h-vs2-egl-size-3-5,henri-daussi-h22-diamond-halo-engagement-ring-14k-white-gold-width--mm-style-princess-1-00ct-g-si1-or-h-vs2-egl-size-3-5.html,Henri Daussi H22 Diamond Halo Engagement Ring-14K White Gold-Style:Princess-1.00ct-G-SI1 or H-VS2-EGL-Width: mm-Size:3.5

vim replace character to \\n

谁说胖子不能爱 提交于 2019-12-03 12:04:26
I need replace all ; to \n , but :%s/;/\n/gc not works See http://vim.wikia.com/wiki/Search_and_replace When searching: \n is newline, \r is CR (carriage return = Ctrl-M = ^M) When replacing: \r is newline, \n is a null byte (0x00). You need to use \r as the replacement instead: :%s/;/\r/gc 来源: https://stackoverflow.com/questions/3965883/vim-replace-character-to-n

Bash bad substitution with subshell and substring

爷,独闯天下 提交于 2019-12-03 09:59:07
A contrived example... given FOO="/foo/bar/baz" this works (in bash) BAR=$(basename $FOO) # result is BAR="baz" BAZ=${BAR:0:1} # result is BAZ="b" this doesn't BAZ=${$(basename $FOO):0:1} # result is bad substitution My question is which rule causes this [subshell substitution] to evaluate incorrectly? And what is the correct way, if any, to do this in 1 hop? First off, note that when you say this: BAR=$(basename $FOO) # result is BAR="baz" BAZ=${BAR:0:1} # result is BAZ="b" the first bit in the construct for BAZ is BAR and not the value that you want to take the first character of. So even if

Creating expression tree in R

吃可爱长大的小学妹 提交于 2019-12-03 07:26:13
问题 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

In VIM, is it possible to use the selected text in the substitute clause without retyping it?

大憨熊 提交于 2019-12-03 06:35:47
Let's say I have a word selected in visual mode. I would like to perform a substitution on that word and all other instances of that word in a file by using s//. Is there a way to use the highlighted text in the s/<here>/stuff/ part without having to retype it? Sure. If you selected the word, just "y"ank it, and then type: :%s/<ctrl-r>"/something else/g Where is pressing ctrl key with r key, and " is just " character. All keypresses: y:%s/<ctrl-r>"/what to put/g<enter> If you searched for your text before you can use CTRL-R / to insert the last search item in your search and replace string.