backreference

passing sed backreference to base64 command

旧城冷巷雨未停 提交于 2019-12-08 03:38:04
问题 What I am trying to achieve is pass the Base64 encoded value captured in the sed regex to the base64 and have it decoded. But the problem is, even though it seems like the correct value is being passed to the function using backreference, base64 complains that the input is invalid. Following is my script - #!/bin/bash decodeBaseSixtyFour() { echo "$1 is decoded to `echo $1 | base64 -d`" } echo Passing direct value ... echo SGVsbG8gQmFzZTY0Cg== | sed -r "s/(.+)$/$(decodeBaseSixtyFour

Negative backreferences in MySQL REGEXP

ⅰ亾dé卋堺 提交于 2019-12-07 15:55:24
问题 MySQL manual is not very detailed about what expressions it supports, so I am not sure if the following is possible with MySQL at all. I am trying to create a query with RLIKE which matches the following. The task is to get from SQL all the sentences which contains at least any two words from the given sentence. Let's say, I have some certain words to use in regex: hello, dog I have following sentences in the database: hello from dog hello hello cat dog says hello dog dog goes away big bad

Vim / sed regex backreference in search pattern

房东的猫 提交于 2019-12-07 13:30:46
问题 Vim help says that: \1 Matches the same string that was matched by */\1* *E65* the first sub-expression in \( and \). {not in Vi} Example: "\([a-z]\).\1" matches "ata", "ehe", "tot", etc. It looks like the backreference can be used in search pattern. I started playing with it and I noticed behavior that I can't explain. This is my file: <paper-input label="Input label"> Some text </paper-input> <paper-input label="Input label"> Some text </paper-inputa> <aza> Some text </az> <az> Some text <

Backslashes in gsub (escaping and backreferencing)

家住魔仙堡 提交于 2019-12-07 11:43:43
问题 Consider the following snippet: puts 'hello'.gsub(/.+/, '\0 \\0 \\\0 \\\\0') This prints (as seen on ideone.com): hello hello \0 \0 This was very surprising, because I'd expect to see something like this instead: hello \0 \hello \\0 My argument is that \ is an escape character, so you write \\ to get a literal backslash, thus \\0 is a literal backslash \ followed by 0 , etc. Obviously this is not how gsub is interpreting it, so can someone explain what's going on? And what do I have to do to

Problem with RewriteCond %{QUERY_STRING}, backreference not dispaying in final URL

心不动则不痛 提交于 2019-12-07 09:53:40
问题 I have the following in my .htaccess file: RewriteCond %{QUERY_STRING} ^route\=product\/category\&path\=35\&page\=([0-9]+)$ RewriteRule ^index\.php$ http://%{HTTP_HOST}/product/category/35/page_$1? [R=301,L] It's not behaving as expected though, when I enter the URL: http://example.com/index.php?route=product/category&path=35&page=2 It gets rewritten to: http://example.com/product/category/35/page_ Could someone tell me what I have done wrong please? Thanks, eb_dev 回答1: To reference

How to replace all the blanks within square brackets with an underscore using sed?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 05:46:57
I figured out that in order to turn [some name] into [some_name] I need to use the following expression: s/\(\[[^ ]*\) /\1_/ i.e. create a backreference capture for anything that starts with a literal '[' that contains any number of non space characters, followed by a space, to be replaced with the non space characters followed by an underscore. What I don't know yet though is how to alter this expression so it works for ALL underscores within the braces e.g. [a few words] into [a_few_words]. I sense that I'm close, but am just missing a chunk of knowledge that will unlock the key to making

Negative backreferences in MySQL REGEXP

时间秒杀一切 提交于 2019-12-06 01:56:18
MySQL manual is not very detailed about what expressions it supports, so I am not sure if the following is possible with MySQL at all. I am trying to create a query with RLIKE which matches the following. The task is to get from SQL all the sentences which contains at least any two words from the given sentence. Let's say, I have some certain words to use in regex: hello, dog I have following sentences in the database: hello from dog hello hello cat dog says hello dog dog goes away big bad dog From those all I want to match only hello from dog dog says hello For now I have it like this: SELECT

Vim / sed regex backreference in search pattern

非 Y 不嫁゛ 提交于 2019-12-05 20:23:59
Vim help says that: \1 Matches the same string that was matched by */\1* *E65* the first sub-expression in \( and \). {not in Vi} Example: "\([a-z]\).\1" matches "ata", "ehe", "tot", etc. It looks like the backreference can be used in search pattern. I started playing with it and I noticed behavior that I can't explain. This is my file: <paper-input label="Input label"> Some text </paper-input> <paper-input label="Input label"> Some text </paper-inputa> <aza> Some text </az> <az> Some text </az> <az> Some text </aza> I wanted to match the lines where the opening and closing tags are matching i

Problem with RewriteCond %{QUERY_STRING}, backreference not dispaying in final URL

爱⌒轻易说出口 提交于 2019-12-05 17:02:32
I have the following in my .htaccess file: RewriteCond %{QUERY_STRING} ^route\=product\/category\&path\=35\&page\=([0-9]+)$ RewriteRule ^index\.php$ http://%{HTTP_HOST}/product/category/35/page_$1? [R=301,L] It's not behaving as expected though, when I enter the URL: http://example.com/index.php?route=product/category&path=35&page=2 It gets rewritten to: http://example.com/product/category/35/page_ Could someone tell me what I have done wrong please? Thanks, eb_dev To reference submatches of a RewriteCond directive, you need to use %n instead of $n : RewriteCond %{QUERY_STRING} ^route=product

Using more than nine back references in an R regex

女生的网名这么多〃 提交于 2019-12-04 15:07:59
The code below does not work, because the replacement string for \10, \11, and so on, cannot be read properly. It reads \10 as \1 and print 0 instead, can you help me fix it? There is an answer in one of the threads, saying that I am supposed to use capturing or naming groups, but I don't really understand how to use them. headline <- gsub("regexp with 10 () brackets", "\\1 ### \\2 ### \\3 ### \\4 ### \\5 ### \\6 ### \\7 ### \\8 ### \\9 ### \\10### \\11### \\12### \\13### \\14### \\15### \\16", page[headline.index]) According to ?regexp , named capture has been available in regexpr() and