ampersand

SED : How to replace a character within a matched pattern using ampersand (&)

北城余情 提交于 2019-12-02 20:34:08
When we match a pattern using sed, the matched pattern is stored in the "ampersand" (&) variable. IS there a way to replace a character in this matched pattern using the ampersand itself ? For example, if & contains the string "apple1", how can I use & to make the string to "apple2" (i.e replace 1 by 2) ? If I guessed right, what you want to do is to apply a subsitution in a pattern matched. You can't do that using & . You want to do this instead: echo apple1 apple3 apple1 apple2 botemo1 | sed '/apple./ { s/apple1/apple2/g; }' This means that you want to execute the command substitution only

simplexml_load_file with & (ampersand) in url with Solr

风流意气都作罢 提交于 2019-12-02 13:04:27
问题 I am using Solr and have the following query which works fine from my browser: http://www.someipaddress.com:8983/solr/select?q=*&fq=shopid:40&start=0&rows=18&fq=manufacturer:"Bausch+%26+Lomb" In part of the return xml I see: <str>manufacturer:"Bausch & Lomb"</str> However when I try and get the above url using simplexml_load_file like this: $xml = simplexml_load_file("http://127.0.0.1:8983/solr/select?q=*&fq=shopid:40&start=0&rows=18&fq=manufacturer:\"Bausch+%26+Lomb\""); I get no results

simplexml_load_file with & (ampersand) in url with Solr

给你一囗甜甜゛ 提交于 2019-12-02 05:52:32
I am using Solr and have the following query which works fine from my browser: http://www.someipaddress.com:8983/solr/select?q=*&fq=shopid:40&start=0&rows=18&fq=manufacturer:"Bausch+%26+Lomb" In part of the return xml I see: <str>manufacturer:"Bausch & Lomb"</str> However when I try and get the above url using simplexml_load_file like this: $xml = simplexml_load_file("http://127.0.0.1:8983/solr/select?q=*&fq=shopid:40&start=0&rows=18&fq=manufacturer:\"Bausch+%26+Lomb\""); I get no results because Solr is being passed the manufacturer string that looks like this (from print_r): [str] => Array (

Overloading Ampersand & operator in R

浪尽此生 提交于 2019-12-02 02:49:33
问题 I like to overload my ampersand operator with paste. So that way I can paste stuff easily. Like this: R> "Hello" & " World" [1] "Hello World" And the way I achieve this is: "&" <- function(...){paste(..., sep = "")} This is all fine and dandy but you lose the ability to use ampersand as a natural "and" operator. What would be the best, fastest most beautiful way to overload my ampersand so that it recognizes when the inputs are logical? TRUE & FALSE == FALSE etc. 回答1: You'll need to use the

batch file deal with Ampersand (&) in folder name

微笑、不失礼 提交于 2019-12-01 00:23:01
Batch file below: @echo off set filelocation=C:\Users\myself\Documents\This&That cd %filelocation% echo %filelocation% pause give the following output: 'That' is not recognized as an internal or external command, operable program or batch file. The system cannot find the path specified. C:\Users\myself\Documents\This Press any key to continue . . . Considering I cannot change the folder name, how do I handle the "&" You need two changes. 1) The extended set syntax with quotes prefix the variable name and at the end of the content 2) delayed expansion to use the variable in a safe way setlocal

Meaning of the ampersand '&' and star '*' symbols in Rust

限于喜欢 提交于 2019-11-30 08:27:00
Despite thoroughly reading the documentation, I'm rather confused about the meaning of the & and * symbol in Rust, and more generally about what is a Rust reference exactly. In this example, it seems to be similar to a C++ reference (that is, an address that is automatically dereferenced when used): fn main() { let c: i32 = 5; let rc = &c; let next = rc + 1; println!("{}", next); // 6 } However, the following code works exactly the same: fn main() { let c: i32 = 5; let rc = &c; let next = *rc + 1; println!("{}", next); // 6 } Using * to dereference a reference wouldn't be correct in C++. So I

Broken string in cookie after ampersand (javascript)

断了今生、忘了曾经 提交于 2019-11-29 16:24:13
I have a slight problem in that the string I'm reading from a cookie is broken after the ampersand. So for example the string "hello & world" would just display "hello ". It is a string that is a short code, and converted to something more meaningful using a switch function, and then displayed within a text box. The switch function works fine, but obviously if it is not reading the full string from the cookie in the first place, then it won't be able to locate the short code within the switch function. I am currently using the following code to read the cookie... document.example.textfield

Meaning of the ampersand '&' and star '*' symbols in Rust

好久不见. 提交于 2019-11-29 11:37:43
问题 Despite thoroughly reading the documentation, I'm rather confused about the meaning of the & and * symbol in Rust, and more generally about what is a Rust reference exactly. In this example, it seems to be similar to a C++ reference (that is, an address that is automatically dereferenced when used): fn main() { let c: i32 = 5; let rc = &c; let next = rc + 1; println!("{}", next); // 6 } However, the following code works exactly the same: fn main() { let c: i32 = 5; let rc = &c; let next = *rc

The best way to store &(Ampersand) in MySQL database

社会主义新天地 提交于 2019-11-29 11:05:19
I'm building a category list and I'm unsure how to store the Ampersand symbol in MySQL database. Is there any problem/disadvantage if I use '&' . Are there any differences from using it in a html format '&amp' ? Using '&' saves a few bytes. It is not a special character for MySQL. You can easily produce the & for output later with PHP's method htmlspecialchars() . When your field is meant to keep simple information, you should use plain text only, as this is in general more flexible since you can generate different kinds of markup etc. later. Exception: the markup is produced by a user whose

Does & need to be & in the meta description?

半腔热情 提交于 2019-11-29 09:34:44
I'm inserting content which has the & sign. I would like to know if it's needed to insert it as & so this sign is read correctly. Like this: <meta name="description" content="lorem lorem S&B lorem lorem"> Or like this: <meta name="description" content="lorem lorem S&B lorem lorem"> You always represent an ampersand in HTML content as & or & , never a bare & . This includes both text between an element's tags, as well as attribute values. No exceptions. This is because & itself denotes the start of an HTML entity reference (as seen above) and can often cause problems when appearing in the