regex

Alertmanager 安装(k8s报警)

 ̄綄美尐妖づ 提交于 2021-02-16 23:38:55
一、下载Alertmanager https://prometheus.io/download/ wget https://github.com/prometheus/alertmanager/releases/download/v0.16.0-alpha.0/alertmanager-0.16.0-alpha.0.linux-amd64.tar.gz #解压 tar xf alertmanager-0.16.0-alpha.0.linux-amd64.tar.gz mv alertmanager-0.16.0-alpha.0.linux-amd64 /usr/local/alertmanager #创建数据目录 mkdir -p /data/alertmanager #创建用户 useradd prometheus chown -R prometheus:prometheus /usr/local/alertmanager /data/alertmanager/ #添加启动服务 vim /usr/lib/systemd/system/alertmanager.service [Unit] Description=Alertmanager After=network.target [Service] Type=simple User=prometheus ExecStart=

Regex: Select and Delete all content of file, except “DATE” format

Deadly 提交于 2021-02-16 21:49:57
问题 I have a file with many dates in the format of 03/07/2017 . For exemple: My lovely letter can't be read... academicsdirectbu.tps 10.7 k 03/07/2017 11:39 -a-- bash: remove all files except last version in file name 02/04/2015 before Table So, I want to match and delete all content except Date format. First I made a regex to find all Dates: \d{1,2}/\d{1,4}/\d{1,4} And I include this into another regex \b(?!(\d{1,2}/\d{1,4}/\d{1,4}))[\w-]+\b But, my second regex, which has to select and Delete

Regex: Select and Delete all content of file, except “DATE” format

老子叫甜甜 提交于 2021-02-16 21:48:20
问题 I have a file with many dates in the format of 03/07/2017 . For exemple: My lovely letter can't be read... academicsdirectbu.tps 10.7 k 03/07/2017 11:39 -a-- bash: remove all files except last version in file name 02/04/2015 before Table So, I want to match and delete all content except Date format. First I made a regex to find all Dates: \d{1,2}/\d{1,4}/\d{1,4} And I include this into another regex \b(?!(\d{1,2}/\d{1,4}/\d{1,4}))[\w-]+\b But, my second regex, which has to select and Delete

How can I grep for a regex containing multiple ranges with at least one occurence

巧了我就是萌 提交于 2021-02-16 21:42:31
问题 Given the following input I'm trying to grep for lines that begin with at least thee digits: 7.3M ./user1 7.3M ./user2 770M ./user3 78M ./user4 737M ./user5 7.6M ./user6 My grep command is not working: grep ^[0-9]+[0-9]+[0-9]+M I don't understand why unfortunately. 回答1: Your regex, ^[0-9]+[0-9]+[0-9]+M , would match the start of string ( ^ ), then 1+ diigts (but it does not because + is not compatible with POSIX BRE that you are using since there is no -E nor -P options), then again 1+ digits

How to get everything within brackets in golang with regex

让人想犯罪 __ 提交于 2021-02-16 21:34:50
问题 I am trying to get everything within the outside brackets of the following sql statement in golang regular expressions. Categories (// = outside bracket PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) )//=outside bracket how would I use regex to only identify the outer brackets and return everything in between the outside brackets? 回答1: All you need is to find the first ( , then match any characters up to the last ) with `(?s)\((.*)\)`

warning: unknown escape sequence '\

爷,独闯天下 提交于 2021-02-16 21:32:22
问题 I'm trying to run a regex through a system command in the code, I have gone through the threads in StackOverflow on similar warnings but I couldn't understand on how to fix the below warnings, it seems to come only for the closed brackets on doing \\}. The warnings seem to disappear but not able to get the exact output in the redirected file. #include<stdio.h> int main(){ FILE *in; char buff[512]; if(system("grep -o '[0-9]\{1,3\}\\.[0-9]\{1,3\}\\.[0-9]\{1,3\}\\.[0-9]\{1,3\}' /home/santosh

regular expression

点点圈 提交于 2021-02-16 21:08:56
问题 How do I write a regular expression to get that returns only the letters and numbers without the asterisks in between ? 回答1: You could use a regex replacement here: my $var = 'RMRIV43069411**2115.82'; $var =~ s/^.*?\D(\d+(?:\.\d+)*)$/$1/g; print "$var"; // 2115.82 The idea is to capture the final number in the string, and then replace with only that captured quantity. Here is an explanation of the pattern: ^ from the start of the input .*? consume all content up until \D the first non digit

regular expression

我与影子孤独终老i 提交于 2021-02-16 21:06:41
问题 How do I write a regular expression to get that returns only the letters and numbers without the asterisks in between ? 回答1: You could use a regex replacement here: my $var = 'RMRIV43069411**2115.82'; $var =~ s/^.*?\D(\d+(?:\.\d+)*)$/$1/g; print "$var"; // 2115.82 The idea is to capture the final number in the string, and then replace with only that captured quantity. Here is an explanation of the pattern: ^ from the start of the input .*? consume all content up until \D the first non digit

regular expression

混江龙づ霸主 提交于 2021-02-16 21:04:37
问题 How do I write a regular expression to get that returns only the letters and numbers without the asterisks in between ? 回答1: You could use a regex replacement here: my $var = 'RMRIV43069411**2115.82'; $var =~ s/^.*?\D(\d+(?:\.\d+)*)$/$1/g; print "$var"; // 2115.82 The idea is to capture the final number in the string, and then replace with only that captured quantity. Here is an explanation of the pattern: ^ from the start of the input .*? consume all content up until \D the first non digit

How do I split a string on different delimiters, but keeping on the output some of said delimiters? (Tokenize a string)

萝らか妹 提交于 2021-02-16 20:53:51
问题 More specifically I want to split a string on any non alpha-numeric character but in the case that the delimiter is not a white space I want to keept it. That is, to the input: my_string = 'Hey, I\'m 9/11 7-11' I want to get: ['Hey' , ',' , 'I' , "'" , 'm', '9' , '/' , '11', '7' , '-' , '11'] Without no whitespace as a list element. I have tried the following: re.split('([/\'\-_,.;])|\s', my_string) But outputs: ['Hey', ',', '', None, 'I', "'", 'm', None, '9', '/', '11', None, '7', '-', '11']