following is the list of instance name from the output of nova command.
nova list
+--------------------------------------+-----------------------------------------+--------+------------+-------------+------------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-----------------------------------------+--------+------------+-------------+------------------------------------------+
| 6cdc00a7-cfe3-4bfe-bbb1-7980ac1c04c0 | haproxy-instance-vms22updateconfar | ACTIVE | - | Running | Orch-Mgmt=10.32.1.40 |
| d0528617-39cd-4098-b34c-0977f5a18414 | gunicon-instance-vms22updateconfar | ACTIVE | - | Running | vms2.1-net=192.168.0.248 |
| e89dd43d-8021-47c6-9f55-39d8bce3c11b | nsoshim-instance-vms22updateconfar | ACTIVE | - | Running | App-Mgmt=10.20.0.126 |
| b7ea9059-834c-4196-8706-54cfaab3d177 | haproxy-instance-vms22update | ACTIVE | - | Running | App-Mgmt=10.20.0.89 |
| 2d4d22e5-b844-413f-8d36-f8b3eb3dea32 | gunicon-instance-vms22update | ACTIVE | - | Running | App-Mgmt=10.20.0.46 |
| 41c4fdc0-3058-4e39-8207-2c02a611ee22 | nsoshim-instance-vms22update | ACTIVE | - | Running | App-Mgmt=10.20.0.217 |
|
SUBDOMAIN=vms22update
nova list | grep "\-instance-$SUBDOMAIN"
gunicon-instance-vms22updateconfar
haproxy-instance-vms22updateconfar
nsoshim-instance-vms22updateconfar
gunicon-instance-vms22update
haproxy-instance-vms22update
nsoshim-instance-vms22update
I want to see instance ends with only vms22update
I tried nova list | grep "-instance-^$SUBDOMAIN$"
it is not listing anything.
#Chris_vr: Thanks for the hint posting my comment as an answer:
You could try this:
nova list | awk -F"|" '{print $3}' | sed 's/ *$//' | grep -E "vms22update\$"
Get output by executing nova list
Split by |
Remove whitespaces
grep for lines ending with vms22update
Related
I want to extract matches from a string column for each id. How can I achieve that?
+--------+---------------------------------------+
| id | text |
+--------+---------------------------------------+
| fsaf12 | Other Questions,Missing Document |
| sfas11 | Others,Missing Address,Missing Name |
+--------+---------------------------------------+
Desired output:
+--------+------------------+
| id | extracted |
+--------+------------------+
| fsaf12 | Other Questions |
| fsaf12 | Missing Document |
| sfas11 | Others |
| sfas11 | Missing Address |
| sfas11 | Missing Name |
+--------+------------------+
Here is the query for sample data: FIDDLE
You can use regexp_split_to_table for your requirement like below:
WITH t1 AS (
SELECT 'fsaf12' AS id, 'Other Questions,Missing Document' AS text UNION ALL
SELECT 'sfas11', 'Others,Missing Address,Missing Name'
)
SELECT id, regexp_split_to_table(text,',')
FROM t1
OUTPUT
| id | extracted |
|-----------|-----------------------|
| fsaf12 | Other Questions |
| fsaf12 | Missing Document |
| sfas11 | Others |
| sfas11 | Missing Address |
| sfas11 | Missing Name |
DEMO
Postgres is not my forte at all but based on this older post on SO you could try to use unnest(). I included a TRIM() to remove possible railing spaces after a split:
SELECT id, TRIM(unnest(string_to_array(text, ','))) as "extracted" FROM t1;
Or, if you want to use regexp_split_to_table():
SELECT id, regexp_split_to_table(text, '\s*,\s*') as "extracted" FROM t1;
Here we matches 0+ whitespace characters, a literal comma and again 0+ whitespace characters.
Sample Data:
+---------------------------------------------------------------------------------+
|refererurl |
+---------------------------------------------------------------------------------+
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|http://mbappgiwwg33nfz2gk43dn4xgo4tpmnsxe6joozuwk5y8.com/ |
|http://mbappgewtgobzgu4dcmrtgy888888.com/ |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|http://mbappgiwwg33nfz2gk43dn4xgo4tpmnsxe6joozuwk5y8.com/ |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|null |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|http://mbappgiwwg33nfz2gk43dn4xgo4tpmnsxe6joozuwk5y8.com/ |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|http://mbappgiwwg33nfz2gk43dn4xgo4tpmnsxe6joozuwk5y8.com/ |
|https://www.tesco.com/direct/party-gifts-flowers/helium-canisters/cat31450037.cat|
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
|https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html |
+---------------------------------------------------------------------------------+
I want regex expression as follows:
a. I want a regex expression which can start extracting backward before '.com' till website name including .com
for eg.
https://www.tesco.com/groceries/dfp/dfp-beaa1a3b14.html --> tesco.com
http://mbappgiwwg33nfz2gk43dn4xgo4tpmnsxe6joozuwk5y8.com --> mbappgiwwg33nfz2gk43dn4xgo4tpmnsxe6joozuwk5y8.com
The following regex seems to work here:
[^.\/]+.com
Demo
Note that this doesn't consider possible URLs like tesco.co.uk.com, in which case we would need to do more work.
Try this one:
(?:http(?:s)?:\/\/(?:www.)?)(.*?)\/
It should work even with url like:
www.example.co.uk/qsdqsd.html
DEMO
I want the words after "test" word from a line in a file. means in actuaaly, i dont want the words coming before "test" word.
thats the pattern...
e.g:
Input:
***This is a*** test page.
***My*** test work of test is complete.
Output:
test page.
work of test is complete.
Using sed:
sed -n 's/^.*test/test/p' input
If you want to print non-matching lines, untouched:
sed 's/^.*test/test/' input
The one above will remove (greedily) all text until the last test on a line. If you want to delete up to the first test use potong's suggestion:
sed -n 's/test/&\n/;s/.*\n//p' input
A pure bash one-liner:
while read x; do [[ $x =~ test.* ]] && echo ${BASH_REMATCH[0]}; done <infile
Input: infile
This is a test page.
My test work of test is complete.
Output:
test page.
test work of test is complete.
It reads all lines from file infile, checks if the line contains the string test and then prints the rest of the line (including test).
The same in sed:
sed 's/.(test.)/\1/' infile (Oops! This is wrong! .* is greedy, so it cuts too much from the 2nd example line). This works well:
sed -e 's/\(test.*\)/\x03&/' -e 's/.*\x03//' infile
I did some speed testing (for the original (wrong) sed version). The result is that for small files the bash solution performs better. For larger files sed is better. I also tried this awk version, which is even better for big files:
awk 'match($0,"test.*"){print substr($0,RSTART)}' infile
Similar in perl:
perl -ne 's/(.*?)(test.*)/$2/ and print' infile
I used the two lines example input file and I duplicated it every time. Every version run 1000 times. The result is:
Size | bash | sed | awk | perl
[B] | [sec] | [sec] | [sec] | [sec]
------------------------------------------
55 | 0.420 | 10.510 | 10.900 | 17.911
110 | 0.460 | 10.491 | 10.761 | 17.901
220 | 0.800 | 10.451 | 10.730 | 17.901
440 | 1.780 | 10.511 | 10.741 | 17.871
880 | 4.030 | 10.671 | 10.771 | 17.951
1760 | 8.600 | 10.901 | 10.840 | 18.011
3520 | 17.691 | 11.460 | 10.991 | 18.181
7040 | 36.042 | 12.401 | 11.300 | 18.491
14080 | 72.355 | 14.461 | 11.861 | 19.161
28160 |145.950 | 18.621 | 12.981 | 20.451
56320 | | | 15.132 | 23.022
112640 | | | 19.763 | 28.402
225280 | | | 29.113 | 39.203
450560 | | | 47.634 | 60.652
901120 | | | 85.047 |103.997
A bunch of us English grad students are studying dialog in Virginia Woolf's novel The Waves, and I've been trying to mark up the novel in TEI. To do this, it would be useful to write a regex that captures the dialog. Thankfully, The Waves is extremely regular, and almost all the dialog is in the form:
'Now they have all gone,' said Louis. 'I am alone. They have gone into the house for breakfast,'
But could continue for several paragraphs. I'm trying to write a regex to match all the paragraphs of a given speaker.
This is discussed briefly in Chris Foster's blog post, where he suggests something like /'([\^,]+,)' said Louis, '(*)'/, although this would only match single paragraphs, I think. This is how I'm thinking through it:
For every paragraph containing the text "said Louis" (or any other character's name) in the first line of the paragraph, match every line until reaching another character's speech, i.e. "said Rhodha."
I could probably do this with a ton of awkward python, but I'd love to know whether this is possible with regex.
It seems, from your link, that the text follows the following rules.
Each "line" is indeed a line in the strict sense, i.e. separated by \n.
Paragraphs are demarcated by two or more consecutive new lines, _i.e. \n\n+.
Only the non-directional single quote ' is used to demarcate speech.
Here's a quick attempt (scroll all the way down to view the match groups)—flawed, I'm sure—but there's enough here that should lead you in the right direction. Note how if you concatenate the three capture groups, idiomatically known as $1, $2, and $3, you get each character's speech, including punctuation between the "said" separator. However, notice how certain quirks of language throw this regular expression off—for example, the fact that we do not close quotes at the end of paragraphs, yet open new quotes if the speech continues into the next paragraph, throws off the whole balanced-quotes strategy—and so do apostrophes.
\n\n.*?'([^^]+?[?]?),?' said (?:[A-Z][a-z]+)(?:([.]) |, )'([^^]+?)'(?=[^']*(?:'[^']')*[^']*\n\n.*'(?:[^^]+?[?]?),?' said (?:[A-Z][a-z]+)(?:[.] |, ))
| | | <----><--> <>|<-------------------><------------>| <----> |<--------------------------------------------------------------------------------->
| | | | | | || | | | ||
| | | | | | || | | | |assert that this end-quote is followed by a string of non-quote characters, then
| | | | | | || | | | |zero or more strings of quoted non-quote characters, then another string of non-
| | | | | | || | | | |quote characters, a new paragraph, and the next "said Bernard"; otherwise fail.
| | | | | | || | | | |
| | | | | | || | | | match an (end-)quote
| | | | | | || | | |
| | | | | | || | | match any character as needed (but no more than needed)
| | | | | | || | |
| | | | | | || | match a (start-)quote
| | | | | | || |
| | | | | | || match either a period followed by two spaces, or a comma followed by one space
| | | | | | ||
| | | | | | |match the "said Bernard"
| | | | | | |
| | | | | | match an (end-)quote
| | | | | |
| | | | | match a comma, optionally
| | | | |
| | | | match a question mark, optionally
| | | |
| | | match any character as needed (but no more than needed)
| | |
| | match a (start-)quote
| |
| match as many non-newline characters as needed (but no more than needed)
|
new paragraph
Rubular matches (an excerpt):
Match 3
1. But when we sit together, close
2.
3. we melt into each
other with phrases. We are edged with mist. We make an
unsubstantial territory.
Match 4
1. I see the beetle
2. .
3. It is black, I see; it is green,
I see; I am tied down with single words. But you wander off; you
slip away; you rise up higher, with words and words in phrases.
I have recently started to use Qt as it is much more intuitive then using win32, I have been playing around with a bunch of the different widgets, and I wan't to try something more complex, but haven't been able to find anything on the Qt reference or Google related to what I want.
I am trying to do something like the Unity3D Inspector box, I get so far with how I would go, but it doesn't seem like there is something for one of the needed components.
I would have a dockable widget, in this I would have a scrollable area, at this point I am looking to add 'components' to this scrollable area, these components will all be somewhat different, they should have the ability to expand/collapse into a single line (The identifier of the component), and upon expansion should be able to have multiple widgets inside of them, such as labels, checkboxes, other collapsable sections, etc.
I must be improperly wording what I am looking for in google as it doesn't seem like there is anything similar to what I want, but it seems like a common idea.
2 solutions:
1/ Manual design
Dock:
*---------------QDockWidget---------------*
| |
| *-------------QScrollArea-------------* |
| | | |
| | *--------ExpandableWidget---------* | |
| | | | | |
| | | | | |
| | | | | |
| | *---------------------------------* | |
| | *--------ExpandableWidget---------* | |
| | | | | |
| | | | | |
| | | | | |
| | *---------------------------------* | |
| | *--------ExpandableWidget---------* | |
| | | | | |
| | | | | |
| | | | | |
| | *---------------------------------* | |
| | *--------VerticalSpacer-----------* | |
| | | | |
| | | | |
| *-------------------------------------* |
| |
*-----------------------------------------*
ExpandableWidget:
ArrowL is a QLabel containing only the arrow indicating whether the widget is collapsed or extended. You set the custom widget to the input widget you want, for example an int input. You hide this widget when collapsing, and show it when expanding.
*------------ExpandableWidget-------------*
| |
| *-------------QVBoxLayout-------------* |
| | | |
| | *-----------QHBoxLayout-----------* | |
| | | *-ArrowL-* *------QLabel------* | | |
| | *---------------------------------* | |
| | | |
| | *---------Custom QWidget----------* | |
| | | | | |
| | *---------------------------------* | |
| | | |
| *-------------------------------------* |
| |
*-----------------------------------------*
Advantage: you can entirely control how the dock behaves.
Drawback: you have to implement this hierarchy by yourself, in a global widget, to ensure its consistency.
2/ QtPropertyBrower
QtPropertyBrowser is part of the now discontinued Qt Solutions (licence). It enables you do to almost what you want in a few code lines.