I want to match string1 and anything that appears in the following lines:
['string1','string2','string3']
['string1' , 'string2' , 'string3']
['string1.domain.com' , 'string2.domain.com' , 'string3.domain.com']
['string1.domain.com:8080' , 'string2.domain.com:8080' , 'string3.domain.com:8080']
Until it encounters the following:
string2
So with the right regex in the above 4 cases the results in bold would be matched:
['string1','string2','string3']
['string1' , 'string2' , 'string3']
['string1.domain.com' , 'string2.domain.com' , 'string3.domain.com']
['string1.domain.com:8080' , 'string2.domain.com:8080' , 'string3.domain.com:8080']
I tried using the following thread to solve my issue with https://regex101.com/
The regex I tried is from Question 8020848, but was not successful with matching the string correctly:
((^|\.lpdomain\.com:8080' , ')(string1))+$
But I was not successful in only matching the part I wanted to in this text:
['string1.domain.com:8080' , 'string2.domain.com:8080' , 'string3.domain.com:8080']
The following is what I received using the regex that you suggested
@@ -108,7 +108,7 @@ node stringA, stringB, stringC,stringD inherits default {
'ssl_certificate_file' => 'test.domain.net_sha2_n.crt',
'ssl_certificate_key_file'=> 'test.domain.net_sha2.key' }
},
- service_upstream_members => ['string1.domain.com:8080', 'string2.domain.com:8080', 'string3.domain.com:8080', 'string4.domain.com:8080', 'string5.domain.com:8080'],
+ service_upstream_members => [ 'string2.domain.com:8080', 'string3.domain.com:8080', 'string4.domain.com:8080', 'string5.domain.com:8080'],
service2_upstream_members => ['string9:8080','string10:8080'],
service3_upstream_members => ['string11.domain.com:8080','string12.domain.com:8080','string13.domain.com:8080'],
service_name => 'test_web_nginx_z1',
As you can see, there is a preceding space that for some reason wasn't removed, even regex101.com demonstrates that all whitespaces are captured in the regex using
'string1[^']*'\s*,\s*
This is what I'm currently using (where server is a variable already defined in the script)
sed -i '' "s/'${server}[^']*'\s*,\s*//"