I have tried a lot to write a regular expression for below line but could not get the success, so requesting some body to help me out in this.
Exp: "APStress_May-15---11.20.3_UIlog".
In the above example APStress and UIlog will be fix rest of the things will get change. i.e
Month ->May,
date -> 15,
Hour -> 11,
Minute ->20,
Seconds ->3
I am writing a script for analysis the logs for that i have to choose this particular file among others .
APStress.*UIlog. Here .* denotes any characters any number of times. Here is an useful link for your future reference. http://www.regex101.com/
Something like:
APStress_(.*?)-(\d{1,2})---(\d{1,2}).(\d{1,2}).(\d{1,2})_UIlog
(not necessarily the best way of doing it)
Try this:
APStress_([\w]+)-([\d]+)(-){3}([\d]{1,2}).([\d]{1,2}).([\d]{1})_UIlog
You could use named capture groups:
/^APStress_(?<Month>\w+)-(?<Date>\d{1,2})---(?<Hour>\d{1,2}).(?<Minute>\d{1,2}).(?<Seconds>\d{1,2})_UIlog$/
dump%+
outout:
("Hour", 11, "Month", "May", "Date", 15, "Seconds", 3, "Minute", 20)
Related
I am trying to use google sheet to create a roster formula, to sum up the duty hour per week using INDEX/MATCH/SUM.
But it's too long, is there any way to simplify the formula?
Also, I realize "MATCH" cannot recognize blank cell (N20), can that be fixed too?
=IFERROR(SUM(INDEX($O$12:$O$20,MATCH(D17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(E17,$N$12:$N$20,0)),INDEX($O$12:$O$20,AND(F17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(G17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(H17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(I17,$N$12:$N$20,0)),INDEX($O$12:$O$20,MATCH(J17,$N$12:$N$20,0))),"Err")
try:
=ARRAYFORMULA(MMULT(IFERROR(REGEXREPLACE(UPPER(B6:H14), "^"&TEXTJOIN("$|^", 1, L1:L10)&"$",
VLOOKUP(REGEXEXTRACT(UPPER(B6:H14), "^"&TEXTJOIN("$|^", 1, L1:L10)&"$"), L1:M10, 2*
SIGN(ROW(A6:A14)), 0)&""), UPPER(B6:H14))*1, TRANSPOSE(COLUMN(B:H))^0))
Franco, since your post says your end goal is to "sum up the duty hour per week," I take that to mean all you need in the end is a single number.
Try this (which will give you total hours for your block that runs B6:H22:
=ArrayFormula(SUM(COUNTIF(B6:H22,$L$1:$L$8)*$M$1:$M$8))
If you need to see the breakdown per code, you can use this:
=ArrayFormula({$L$1:$L$8,COUNTIF(B6:H22,$L$1:$L$8)*$M$1:$M$8})
Just replace "B6:H22" with the reference of each calendar block to get the sum or the breakdown for other weeks.
I have a folder with 100 folders, named like:
parent_folder/05/01/
parent_folder/05/02/
parent_folder/05/03/
parent_folder/05/04/
...
parent_folder/05/29/
parent_folder/05/30/
How can I specify a path, with regex, that would select only the contents of folders 01 to 10, then 11 to 20 and, finally, 21 to 30 ?
I am trying
"parent_folder/05/[1-10]*/*"
but it also selects 11, 12, ... all the way to 19.
EDIT: I want to read a large dataset in pyspark by 10-day intervals, and all suggested answers, so far, seem to fail.
If you want the "10" to be grouped with your 01...09 set, you are going to use something like this:
parent_folder\/05\/(0[1-9]|10)\/
then, for your 10...20 set,
parent_folder\/05\/(1[1-9]|20)\/
and so on.
You can try these regexps with the following link : https://regex101.com/r/cXAYbS/2
In python, you are going to need:
regex = r"parent_folder\/05\/(1[1-9]|20)\/"
The link above has a "python" generator, where you can borrow some code:
https://regex101.com/r/cXAYbS/2/codegen?language=python
How about this:
parent_folder/05/(?:0[1-9]|10)/
The '?:' is used for non-captering groups.
I have document that looks like as follows:
{'id': 123,
'favorites': [5, 3, 7, 8, 1, 9, 2]}
In this document, favorite is of list type. I want to query the latest favorite or first/last 5 favorites. I'm not sure how can I achieve that in DynamoDB. Please help.
After hunting for this question for a while, unfortunately it's not supported by the DynamoDB. May be, it'll be supported in the future.
In current(22 Jun 2021) example of documentation, they used size(info.actors) to get the size.
You can do this:
ConditionExpression='#list[0] = :num',
ConditionExpression='size(#list) = :num',
However, you CANNOT do this:
ConditionExpression='#list[ size(#list)-1 ] = :num',
According to
boto3 documentation, it looks like it's impossible to get the last element.
The best work-around I've found so far is:
reverse all lists, then use #list[0]
use contains(#list, :elem)
I have multiple lines like this <VValue type="int" value="0" /> in files running in Sublime; each where the value increments 0, 1, 2, 3 etc...
I need to change these values, +60. So, 0 would become 60, 1 would be 61 etc.
How do I select the multiple lines and append them with regex in Sublime? I'm not sure of the command to select the number itself... something like \d+ was mentioned in another thread - Sublime Text 2 increment numbers
Note, I skip one number to separate some content in the software the files run in, so it really needs to be a +60 to the value command instead of just a direct replace all and increment (as in the thread above) as that would throw off the one that was skipped, if you follow me. For example, it could be 0, 1, 3, 4, 5 that should equal 60, 61, 63, 64, 65 and not 60, 61, 62, 63, 64.
Do I need something like TextPastry, and to use the Number Sequence Command? If so, I'm not sure how that works and would appreciate comments.
Thanks for any help :)
Edit; I think I can use the Auto Step feature in Text Pastry? Can someone kindly run me through this how to... install and use.
Unfortunately, Text pastry is not powerful enough (as far as I know). You need some evaluator package. We'll use Sublime-Evaluate here.
To install it (assuming you have package manager installed) simply
Command+Shift+p -> ip -> Enter -> evaluate -> Enter
Now just select the numbers you want to change (search with regex enabled):
(?<=<VValue type="int" value=")\d+(?=" />)
Alt+Enter. Now they are selected.
Right arrow to go after the selection. Type +60. Now Ctrl+Shift+← 3 times to select
0+60
1+60
...
n+60
on each line. Now Command+Shift+e and you are done (alternatively, you can Command+Shift+p -> evaluate -> Enter.
this is my first question on stackoverflow so be tolerant with a french rookie ;)
I have to simplify a MongoDB query and I've discovered this tool this morning on docs.mongodb.org and I really need to understand the methodology to continue to learn by myself.
Here is the query :
{$and: [{x: 2}, {y: 3}, {$and: [{z: 4}]}, {$or: [{name:{$regex: "toto."}}, {name:{$regex: "toto."}}]}]}
Thanks
Basically in SQL it is:
x = 3 AND y = 3 AND z = 4 AND (name LIKE 'toto%' OR name LIKE 'toto%')
This query can be massively simplified and I am not sure what tool you used to get this query, however, it can be brought down to:
{x: 2, y: 3, z: 4, name: {$in: [/^toto.*/, /^toto.*/]}}
This is since the default operator between query parts is actually $and so you only need $and in very specific cases, i.e. when you need to separately $and two clauses in a field or need to $and two separate $ors that, logically cannot be put together (for some reason).
I should note that in some drivers you need to replace the $in with an $or it depends on the constructs within the driver however, BSON regex objects (not the $regex operator) should be able to function within $in clauses etc.